a006.
一元二次方程式
| From: [113.61.220.125] |
發表日期
:
2014-01-26 16:06
/code_1728194.cpp: In function ‘int main()’: /code_1728194.cpp:4: error: ‘cin’ was not declared in this scope /code_1728194.cpp:7: error: ‘cout’ was not declared in this scope /code_1728194.cpp:11: error: ‘cout’ was not declared in this scope /code_1728194.cpp:15: error: ‘sqrt’ was not declared in this scope /code_1728194.cpp:17: error: ‘cout’ was not declared in this scope
#include<iostream>
#include<math.h>
using namespace std;
main()
{
int a, b, c, x, x1, x2;
while(cin >> a >> b >> c)
{
if ((b*b-(4*a*c))<0)
cout << "No real root";
if ((b*b-(4*a*c))==0)
{
x=-b/2*a;
cout << "Two same roots x=" << x;
}
if ((b*b-(4*a*c))>0)
{
x1=(-b+ sqrt(b*b-(4*a*c)))/2*a;
x2=(-b- sqrt(b*b-(4*a*c)))/2*a;
cout << "Two different roots x1=" << x1 << " , x2=" << x2;
}
}
return 0;
}