大家看一个程序
#include<iostream>#include<cmath>
using namespace std;
int main()
{
float a,b,c,x1,x2;
cin>>a>>b>>c;
x1=(-b+sqrt(b*b-4*a*c))/(2*a);
x2=(-b-sqrt(b*b-4*a*c))/(2*a);
cout<<"x1="<<x1<<endl;
cout<<"x2="<<x2<<endl;
return 0;
}
return 0;到底把值返回到那里,这个程序到底和下面这个区别再那里?为什么不用void?
#include<iostream>
#include<cmath>
using namespace std;
void main()
{
float a,b,c,x1,x2;
cin>>a>>b>>c;
x1=(-b+sqrt(b*b-4*a*c))/(2*a);
x2=(-b-sqrt(b*b-4*a*c))/(2*a);
cout<<"x1="<<x1<<endl;
cout<<"x2="<<x2<<endl;
}