#11360: c++ answer


TzuchunChen (陳子濬)


#include <iostream>
#include <math.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

using namespace std;

int main(int argc, char** argv) {
 
 int a, b, c, d;
 
 while(cin >> a >> b >> c)
 {
  d=b*b-4*a*c;
  
  if(d>0){cout <<"Two"<<" "<<"different"<<" "<<"roots"<<" "<<"x1="<<(-b+pow(d,0.5))/(2*a)<<" "<<","<<" "<<"x2="<<(-b-pow(d,0.5))/2<<endl;}
  
  else if(d==0){cout<<"Two"<<" "<<"same"<<" "<<"roots"<<" "<<"x="<<(-b)/(2*a)<<endl;}
  
  else if(d<0){cout<<"No"<<" "<<"real"<<" "<<"root"<<endl;}
 }
 
 return 0;
}