好吧 C.....
- #include<math.h>
- main()
- {
- float a,b;
- double s,h;
- double f(double x);
- int n,i;
- printf("Input integral area a,b:");
- scanf("%f,%f",&a,&b);
- printf("Input n:");
- scanf("%d",&n);
- h=(b-a)/n;
- s=0.5*h*(f(a)+f(b));
- for(i=1;i<=n-1;i++)
- s=s+h*f(a+i*h);
- printf("\nThe value is:%lf ",s);
- }
复制代码 |