C++编程,时候错了找不到“math”文件,怎么办?
程序如下;#include <iostream>
#include <math>
using namespace std;
int main()
{
int i,j,n,k,c;//n为方程的阶数,c为希望的迭代的次数
float e,s,m;//误差极限
float a[3][3],b[3],d[3];
float x1[3],x0[3];//x1,x0分别相当于x(k+1),x(k)
cout<<"输入方程的阶数n="<<endl;
cin>>n;
cout<<"输入矩阵a(i,j)="<<endl;
for(i=1,i<=n,i++)
{
for(j=1,j<=n,j++)
{
cin>>a[i][j];
}
}//矩阵的输入
cout<<"输入向量b(i)"<<endl;
for(i=1,i<=n,i++)
{
cin>>b[i];
}
cout<<"输入希望迭代的次数c="<<endl;
cin>>c;
cout<<"输入误差极限e="<<endl;
cin>>e;
//开始迭代
for(k=1,k<=c,k++)
{
for(i=1,i<=n,i++)
{
s=0;//对s进行赋值
for (i=1,i<=n,i++)
{
x1[i]=0,x0[i]=0;//对x1[i],x0[i]进行赋值
}
for(j=1,j<=n,j++)
{
if(j!=i)
{s=s+a[i][j]*x0[j];}
}
x1[i]=(b(i)-s)/a[i][i];//完成一次迭代
}
for(i=1,i<=n,i++)
{d[i]=x1[i]-x0[i];}//d[i]为下面误差分析用
if(m=max(d[1],d[2],d[3])<=e)//比较误差
{cout<<"迭代的次数k="<<k<<endl;
cout<<"方程的解为"<<endl;
for(i=1,i<=n,i++)
{cout<<x1[i]<<" ";
cout<<endl;
break;}//输出x1[i]
for(i=1,i<=n,i++)
{x0[i]=x1[i];}//把K+1的值赋给K
}//完成迭代
cout<<"迭代的次数k="<<c<<endl;
cout<<"方程的解为"<<endl;
for(i=1,i<=n,i++)
{cout<<x1[i]<<" ";
cout<<endl;}
return 0;
}
出现的错误:
d:\documents and settings\administrator.27611bfecbf8430\雅可比.cpp(2) : fatal error C1083: Cannot open include file: 'math': No such file or directory
执行 cl.exe 时出错.
雅可比.obj - 1 error(s), 0 warning(s