简单的一个:#include
#include
using namespace std;
int main() {
int a, b, c;
scanf_s("%d%d%d", a, b, c);
if (a == 0 || a > 1000 || b > 1000 || c > 1000) {
return 0;
}
int key = b*b -4*a*c;
int r0, r1;
if (key < 0) {
printf("No real root");
return 0;
}
r0 = (-b + sqrt(key)) / 2 * a;
if (key == 0) {
printf("Two same roots x= %d", r0);
}
else {
r1 = (-b - sqrt(key)) / 2 * a;
printf("Two different roots x1= %d , x2= %d ", r0, r1);
}
return 0;
}