#include<iostream> #include <string> #include <math.h> using namespace std; main() { int a,b,c,d,e,f,g; while (cin>>a>>b>>c) { d=(-b+sqrt(b*b-4*a*c))/(2*a); e=(-b-sqrt(b*b-4*a*c))/(2*a); f=b*b-4*a*c; if(f>0) { cout<<"Two different roots x1="<<d<<" , x2="<<e<<endl; } else if(f==0) { cout<<"Two same roots x="<<d<<endl; } else { cout<<"No real root"<<endl; } } return 0; }
#include #include #include using namespace std; main() { int a,b,c,d,e,f,g; while (cin>>a>>b>>c) { d=(-b+sqrt(b*b-4*a*c))/(2*a); e=(-b-sqrt(b*b-4*a*c))/(2*a); f=b*b-4*a*c; if(f>0) { cout<<"Two different roots x1="<<d<<" , x2="<<e<<endl; } else if(f==0) { cout<<"Two same roots x="<<d<<endl; } else { cout<<"No real root"<<endl; } } return 0; }
要貼程式碼請使用「一般」留言而非「解題報告」。