//Ex5_30.cpp
#include "iostream" 
#include "cmath" 
using namespace std;
double f(double x) 
{return 3*x*x+1;} 
double area(double a,double b,int n) 
{int sum;double h=(b-a)/n; 
 sum=(f(a)+f(b))/2; 
 int x=a+h; 
 for(int i=1;i<n;i++) 
	{sum+=f(x);x+=h;} 
 return sum*h; 
} 
void main() 
{double a(1),b(3);
 int n; 
 cout<<"请输入积分区间等分数:"; 
 cin>>n; 
 cout<<"S("<<a<<","<<b<<")="<<area(a,b,n)<<endl; 
} 
