我对编程和编码非常陌生,所以我遇到了一些我似乎无法理解的问题。我真的找到答案,但徒劳无功。之前 '{' 令牌编译器错误初学者问题
;和
预期 '':
编译器中提到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") ; }
谢谢你的帮助。我将通过使用您提供的解决方案解决问题。 –