請各位大大幫個忙~
以下是我的程式碼
#include <iostream>
#include <cmath>
using namespace std;
int main(){
int a,b,c,D,x,x1,x2;
while(cin >> a>> b>>c)
D = b*b-4*a*c;
x = -b/(2*a);
x1 =((-b + sqrt (D))/(2*a));
x2 = ((-b - sqrt (D) )/(2*a));
if (D<0)
cout << "No real root "<<endl;
else if (D==0)
cout << "Two same roots x=" << x << endl;
else
cout << "Two different roots x1=" << x1 << ", x2=" << x2 << endl;
return 0;
}
*** 第 1 點 (20%):WA (line:1)
您的答案為: Two different roots x1= 3, x2=2
正確答案為: Two different roots x1=3 , x2=2