码迷,mamicode.com
首页 > 其他好文 > 详细

求x在区间[a,b]上的积分

时间:2017-07-22 20:58:02      阅读:196      评论:0      收藏:0      [点我收藏+]

标签:scan   include   math   put   class   mod   window   分区   ons   

#include <stdio.h>
#include <windows.h>
#include <math.h>

void Pos(int x,int y)
{
    COORD pos;
    HANDLE hOutput;
    pos.X = x;
    pos.Y = y;
    hOutput = GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleCursorPosition(hOutput, pos);
}

int main()
{
    int n=0;
    double x,y=0.0,result=0.0,a,b;
    system("mode con cols=50 lines=20");
    system("title                                                     求y=x的积分");
    printf("请输入积分区间 a,b:[   ]");
    Pos(20,0);
    scanf("%lf,",&a);
    Pos(23,0);
    scanf("%lf",&b);
    x=a;
    while(x<b)
    {
        y += x;
        x += 0.0001;
        n++;
    }
    result = ( (b-a)/n ) * y;
    Pos(0,2);
    printf("y=x在积分区间[%.2lf,%.2lf]的结果为:%.4lf\n",a,b,result);
    return 0;
}

 

求x在区间[a,b]上的积分

标签:scan   include   math   put   class   mod   window   分区   ons   

原文地址:http://www.cnblogs.com/darkchii/p/7222377.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!