标签: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; }
标签:scan include math put class mod window 分区 ons
原文地址:http://www.cnblogs.com/darkchii/p/7222377.html