#include <stdio.h>
#include <math.h>
float main()
{
float a,b,c,x1,x2,flag=0;
scanf("%f,%f,%f",&a,&b,&c);
if(a!=0)
{
flag=b*b-4*a*c;
if(flag<0)
printf("No real roots.");
if(flag>=0)
{
x1=(-b+sqrt(flag))/(2*a);
x2=(-b-sqrt(flag))/(2*a);
printf("x1=%.0f,x2=%.0f",x1,x2);
}
}
else
printf("No real roots.");
}
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
float a,b,c,x1=0,x2=0,flag=0;
scanf("%f,%f,%f",&a,&b,&c);
if(a!=0)
{
flag=b*b-4*a*c;
if(flag<0)
cout<<"No real roots."<<endl;
if(flag>=0)
{
x1=(-b+sqrt(flag))/(2*a);
x2=(-b-sqrt(flag))/(2*a);
cout<<"x1="<<x1<<','<<"x2="<<x2<<endl;
}
}
else
cout<<"No real roots."<<endl;
}
|