#include<iostream.h>
#include<math.h>
int n;
double f(double x)
{
return 1/(1+x*x);
}
double AttoTrap(double(*f)(double),double a,double b)
{
int i;
double x,s,h=b-a;
double t1,t2=h/2.0*(f(a)+f(b));
int n=1;
do
{
s=0.0;t1=t2;
for(i=0;i,n;i++)
{
x=a+i*h+h/2;
s+=f(x);
}
t2=(t1+s*h)/2.0;
n*=2;
h/=2;
}
while(fabs(t2-t1)>1e-6);
return t2;
}void main ()
{ double s;
double f(double);
double AutoTrap(double (*f)(double),double,double);
s=AutoTrap(f,0.0,1.0);
cout<<"n="<<n<<" "<<"x="<<s<<endl;
}
编译出现如下错误:
****.obj : error LNK2001: unresolved external symbol "double __cdecl AutoTrap(double (__cdecl*)(double),double,double)" (?AutoTrap@@YANP6ANN@ZNN@Z)
Debug/****.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
#include<math.h>
int n;
double f(double x)
{
return 1/(1+x*x);
}
double AttoTrap(double(*f)(double),double a,double b)
{
int i;
double x,s,h=b-a;
double t1,t2=h/2.0*(f(a)+f(b));
int n=1;
do
{
s=0.0;t1=t2;
for(i=0;i,n;i++)
{
x=a+i*h+h/2;
s+=f(x);
}
t2=(t1+s*h)/2.0;
n*=2;
h/=2;
}
while(fabs(t2-t1)>1e-6);
return t2;
}void main ()
{ double s;
double f(double);
double AutoTrap(double (*f)(double),double,double);
s=AutoTrap(f,0.0,1.0);
cout<<"n="<<n<<" "<<"x="<<s<<endl;
}
编译出现如下错误:
****.obj : error LNK2001: unresolved external symbol "double __cdecl AutoTrap(double (__cdecl*)(double),double,double)" (?AutoTrap@@YANP6ANN@ZNN@Z)
Debug/****.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
解决方案 »
- 向各位大侠请教一个关于opencv里面cvFindContours()函数使用的问题,在线求解答
- 如何用AfxMessageBox()弹出对话框,让其他的进程都用不了
- Shell_NotifyIcon NOTIFYICONDATA的一个疑问
- 做学生管理系统时,遇到的两个问题,请高手帮忙解决!
- 用CInternetSession,老是提示“与服务器的连接被重置”,怎么搞的?,头都晕了!!!!
- 这个界面怎么做?
- 一个combo box的疑问
- 寻求帮助!!!!
- 实现U盘初始化流程。
- 跪求大神帮忙写一个VC6.0环境下MFC化的猴子选大王游戏
- vc中怎样才能像vb那样可以将一段代码注释掉?
- 在VC 6.0 中 如何让窗口总在最前面?
{ double s;
// double f(double);
// double AutoTrap(double (*f)(double),double,double);
s=AttoTrap(f,0.0,1.0);
cout<<"n="<<n<<" "<<"x="<<s<<endl;
}那个AutoTrap函数名错了, 和前面的不一样。