#include<iostream>
using namespace std;
#include<cmath>
int main()
{
float a,b,c;
double x1,x2,s;
cout<<"please enter the num:";
cin>>a>>b>>c;
if(b*b-4*a*c>=0)
{
x1=(-b+sqrt(b*b-4*a*c))/(2*a);
x2=(-b-sqrt(b*b-4*a*c))/(2*a);
cout<<"x1="<<x1<<"\n"<<"x2="<<x2<<endl;
}
else
cout<<"方程无实根"<<endl;
return 0;
}
时间: 2024-10-05 19:26:17