楼下的房客小说txt:这个C++程序哪儿有错?我找了好久了,始终找不到

来源:百度文库 编辑:神马品牌网 时间:2024/04/28 11:47:01
#include<iostream>
#include<math.h>
using namespace std;
float x1,x2,disc,p,q;
int main()
{void greater_than_zero(float,float);
void equal_to_zero(float,float);
void smaller_than_zero(float,float);
float a,b,c;
cout<<"input a,b,c:";cin>>a>>b>>c;
disc=b*b-4*a*c;
cout<<"root:"<<endl;
if(disc>0)
{greater_than_zero(a,b);
cout<<"x1="<<x1<<",x2="<<x2<<endl;}
else if(disc==0)
{equal_to_zero(a,b);
cout<<"x1="<<x1<<",x2="<<x2<<endl;}
else
{smaller_than_zero(a,b);
cout<<"x1="<<p<<"+"<<q<<"i"<<endl;cout<<"x2="<<p<<"-"<<q<<"i"<<endl;}
return 0;}
void greater_than_zero(float a,float b)
{x1=(-b+sqrt(disc))/(2*a);x2=(-b-sqrt(disc))/(2*a);}
void equa_to_zero(float a,float b)
{x1=x2=(-b)/(2*a);}
void smaller_than_zero(float a,float b)
{p=-b/(2*a);q=sqrt(-disc)/(2*a);}
程序很简单的,一个主函数,三个调用函数.
调试正确,编译EXE时出2个错:
提示如下Text1.obj : error LNK2001: unresolved external symbol "void __cdecl equal_to_zero(float,float)" (?equal_to_zero@@YAXMM@Z)
Debug/Text1.exe : fatal error LNK1120: 1 unresolved externals
不用回答了!!错误已经找出来了,原来equal少写个l
真是粗心...掌握个知识可不容易