编译0错误,但连接有无,不知道问题出哪了,求解!!!1
爱上ios 2012-11-20 12:44:40 下面是我编写的程序:
/*
求 sin(π/2),sin(56°),cos(87°),cos(π/3)的值。
*/
#include <iostream>
#include<cmath>
using namespace std;
const double pai=3.1415926;
double mysin(double);
double mycos(double);
double myjds(double);
int main(){
cout<<"sin(π/2)的值为:"<<mysin(pai/2);
cout<<",利用库函数求的sin(π/2)的值为:"<<sin(pai/2)<<endl<<endl;
cout<<"sin(56°)的值为"<<sin((56.0/180)*pai);
cout<<",利用库函数求的sin(56°)的值为:"<<endl<<endl;
cout<<"cos(87°)的值为:"<<mycos((87.0/180)*pai);
cout<<",利用库函数求的cos(87°)的值为:"<<endl<<endl;
cout<<"cos(π/3)的值为:"<<mycos(pai/3);
cout<<",利用用库函数求的cos(π/3)的值为:"<<cos(pai/3)<<endl;
return 0;
}
double mysin(double x)
{
double sum=1,x_pow=1,t;
int n=1,g=1,r=1;
do
{
g=g*(n+1)*(n+2);
x_pow=x*x;
r=-r;
t=x_pow/g*r;
sum+=t;
n+=2;
}while(myjds(t)>0.00001);
return sum;
}
double mycos(double x)
{
double sum=1,x_pow=1,t;
int n=0,g=1,r=1;
do
{
g=g*(n+1)*(n+2);
x_pow=x*x;
r=-r;
t=x_pow/g*r;
sum+=t;
n+=2;
}while(myjds( t)>0.00001);
return sum;
}
接着是错误的提示:
--------------------Configuration: Cpp1 - Win32 Debug--------------------
Linking...
Cpp1.obj : error LNK2001: unresolved external symbol "double __cdecl myjds(double)" (?myjds@@YANN@Z)
Debug/Cpp1.exe : fatal error LNK1120: 1 unresolved externals
执行 link.exe 时出错.
Cpp1.exe - 1 error(s), 0 warning(s)
-------------------------
我真搞不懂错在哪了,,,,,,,,