[問題] C++ 一元二次方程式的解...
#include <cstdlib>
#include <iostream>
#include <cmath>
using namespace std;
int main(int argc, char *argv[])
{
double a,b,c,d,x,y,x1,x2;
y=a*x*x+b*x+c;
cout << "The program will caculate the equation./n";
cout << "Please enter a:";
cin >> a;
cout << "Please enter b:";
cin >> b;
cout << "Please enter c:";
cin >> c;
d=b*b-4*a*c;
if (d>=0)
x1=(-b+sqrt(b*b-4*a*c))/(2*a);
cout << " The answer x1 is " ;
x2=(-b-sqrt(b*b-4*a*c))/(2*a);
cout << " The answer x2 is " ;
else
cout << "There is no answer. ";
system("PAUSE");
return EXIT_SUCCESS;
}
我用Dev-C++ Complier之後他會跑出錯誤
expected primary-expression before "else"
可是我怎麼看都沒有錯...登登XD
先謝謝大家囉(鞠躬)
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 218.211.94.136
推
11/28 14:15, , 1F
11/28 14:15, 1F
推
11/28 20:51, , 2F
11/28 20:51, 2F
推
12/04 16:11, , 3F
12/04 16:11, 3F
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 1 之 3 篇):
Programming 近期熱門文章
PTT數位生活區 即時熱門文章