我對編程和編碼非常陌生,所以我遇到了一些我似乎無法理解的問題。我真的找到答案,但徒勞無功。之前 '{' 令牌編譯器錯誤初學者問題
;和
預期 '':
編譯器中提到2個錯誤:
在函數 'intmain()'
#include<iostream> #include<math.h> using namespace std; main() { float a, b, c, D, x1, x2, x; cout<<"enter the value of a :"; cin>>a; cout<<"enter the value of b :"; cin>>b; cout<<"enter the value of c :"; cin>>c; D= b*b-4*a*c; if(D>0) { x1= (-b-sqrt(D))/(2*a); x2= (-b+sqrt(D))/(2*a); cout<<"the roots of the equation are"<<x1<<"and"<<x2<<" \n"; } else if (D=0) {x= -b/(2*a); cout<<"the double root of the equation is"<<x<<" \n"; } else (D<0) { cout<<"no solution \n:"; } system("pause") ; }
謝謝你的幫助。我將通過使用您提供的解決方案解決問題。 –