#include <stdio.h> #include <math.h> int main() { int a, b, c; float e, f, g; printf("请输入三个数字:"); scanf("%d%d%d", &a, &b, &c); e = b * b - 4 * a * c; f = - b + sqrt(e); g = - b - sqrt(e); f = f * 0.5 / a; g = g * 0.5 / a; if(f>g) { printf("%.2f%.2f\n", f, g); } else{ printf("%.2f%.2f\n", g, f); } return 0; } |
Double click to view unformatted code.