c++

4396y 发表于 1年前 · 关联问题 一元二次方程求解

include "pch.h"

include

define _USE_MATH_DEFINES

include<math.h>

using namespace std;

int main() {

int a, b, c; cin >> a >> b >> c; if (a < 1 || c>10) { return 0; } float reslut = b * b - 4 * a*c; if (reslut == 0) { cout << "YES\n"; float x1 = -b / (2 * a); float x2 = x1; printf("%f %f",x1,x2); } else if(reslut>0) { cout << "YES\n"; float x1 = (-b + sqrt(reslut))/(2*a); float x2 = (-b - sqrt(reslut)) / (2 * a); printf("%f %f", x1, x2); } else { cout << "NO\n"; }

}