为什么用VC++6.0编译文件没有错误,但是在执行的时候却不显示?

#include<iostream>
#include<stdlib.h>
#include<cmath>
using namespace std;
int mian()
{
double lg(double,double,double); //申明自定义函数//
double yg(double,double,double); //申明自定义函数//
double wg(double,double,double); //申明自定义函数//
double a,b,c;
cout<<"a*a*x+b*x+c=0"<<endl;
cout<<"Please input a,b,c!"<<endl;
cin>>a >>b >>c;
if(b*b-4*a*c>0) lg(a,b,c); //判断b*b-4*a*c的值来选择函数调用//
if(b*b-4*a*c==0) yg(a,b,c); //判断b*b-4*a*c的值来选择函数调用//
if(b*b-4*a*c<0) wg(a,b,c); //判断b*b-4*a*c的值来选择函数调用//
system("PAUSE");
return (0);
}
int lg(double a,double b,double c)
{
double x1,x2;
cout<<"方程有2个实数根!"<<endl;
x1=(-b+sqrt(b*b-4*a*c))/(2*a);
x2=(-b-sqrt(b*b-4*a*c))/(2*a);
cout<<"x1="<<x1<<endl<<"x2="<<x2<<endl;
return (0);
}
int yg(double a,double b,double c)
{
double x;
cout<<"方程有2个相等的解!"<<endl;
x=-b/a*a;
cout<<"x1=x2="<<x<<endl;
return (0);
}
int wg(double a,double b,double c)
{
cout<<"根据a的不同有2种情况!";
if(a>0) cout<<"当a>0时,抛物线为下凸,与x轴没有交点,小于0恒不成立,x无解."<<endl;
if(a<0) cout<<"当a<0时,抛物线为上凸,与x轴没有交点,小于0恒成立,x属于实数R."<<endl;
return (0);
}
程序如上面所写,在编译的时候没有错误,但是在执行的时候不显示问题,而且有3段提示看不懂请高手解答下:
方程.obj : error LNK2001: unresolved external symbol "double __cdecl wg(double,double,double)" (?wg@@YANNNN@Z)
方程.obj : error LNK2001: unresolved external symbol "double __cdecl yg(double,double,double)" (?yg@@YANNNN@Z)
方程.obj : error LNK2001: unresolved external symbol "double __cdecl lg(double,double,double)" (?lg@@YANNNN@Z)
改成double型返回后还是不能显示!
提示是:LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/方程.exe : fatal error LNK1120: 1 unresolved externals

函数声明和定义不符合,导致在运行的时候找不到你声明的三个返回double 的函数。

在函数定义的时候把返回值改成double就没问题了。
温馨提示:答案为网友推荐,仅供参考
相似回答