#include<iostream>
#include<cmath>
#include <iomanip>
using namespace std;
int main()
{
int a,b,c;
void bigger(int,int,int);
void smaller(int,int,int);
void equal(int,int);
cout<<"输入abc的值:";
cin>>a>>b>>c;
double dec = b*b-4*a*c;
if(dec > 0){
bigger(a,b,c);
}else if(dec<0){
smaller(a,b,c);
}else{
equal(a,b);
}
return 0;
}
void bigger(int n ,int m ,int j){
double x1,x2;
double temp =sqrt(m*m-4*n*j);
x1 = ((-1)*m+temp)/(2*n);
x2 = ((-1)*m-temp)/(2*n);
cout<<"值为:"<<"x1="<<x1<<" "<<"x2="<<x2<<endl;
}
void equal(int n ,int m ){
double x;
x=((-1)*m)/(2*n);
cout<<"值为:"<<"x="<<x<<endl;
}
void smaller(int n ,int m ,int j){
cout<<"无解"<<endl;
}
![](https://i-blog.csdnimg.cn/blog_migrate/1335f9a77437d0132b05f48577178a71.png)