这句话是什么意思?
not all control paths return a value这句话翻译过来是“没有控制路径返回一个值”
就比如return语句不能带回以一函数,然后执行这个函数得到一值吗?
#include <iostream>
#include <cmath>
using namespace std;
float first(float x,float y,float z);
float second(float x,float y,float z);
void third();
int main()
{
float judge(float x,float y,float z);
float a,b,c;
cin>>a>>b>>c;
judge(a,b,c);
return 0;
}
float judge(float x,float y,float z)
{
if(y*y-4*x*z>0)
return(first(x,y,z));
if(y*y-4*x*z==0)
return(second(x,y,z));
if(y*y-4*x*z<0)
third();
}
float first(float x,float y,float z)
{
float x1,x2;
x1=(-y-sqrt(y*y-4*x*z))/(2*x);
x2=(-y+sqrt(y*y-4*x*z))/(2*x);
cout<<x1<<' '<<x2<<endl;
return 0;
}
float second(float x,float y,float z)
{
float x0;
x0=-y/(2*x);
cout<<x<<endl;
return 0;
}
void third()
{
cout<<"无实数根"<<endl;
}