#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;double x1, x2, q,p,m;
void s1(double a, double b, double c) {
x1 = (-b + sqrt(m)) / 2 * a;
x2 = (-b - sqrt(m)) / 2 * a;
cout << x1 << " " << x2 << endl;
}
void s2(double a,double b,double c){
x1 = x2 = (-b) / (2 * a);
cout << x1 << " " << x2 << endl;
}
void s3(double a,double b,double c){
q = (-b) / (2 * a);
p = sqrt(-m) / (2 * a);
cout << "x1=" << q << "+" << fixed << setprecision(3) << p << "i" << " " << "x2 =" << q << "-" << fixed << setprecision(3) << p << "i" << endl;
}
int main()
{
double a, b, c;
2022-08-04 22:39:57
Blank 2022-08-04 22:40:08 |
接 cin >> a >> b >> c; m = b * b - 4 * a * c; if (m > 0)s1(a, b, c); else if (m == 0)s2(a, b, c); else s3(a, b, c); return 0; }
Blank 2022-08-04 22:40:46 |
我想问一下,为什么我用自己的软件运行可以成功,可是在网站上提交它说我答案错误?