5 solutions
-
0
#include <stdio.h> #include <math.h> //要用到开平方和平方 int main() { double a, b, c; scanf("%lf %lf %lf", &a, &b, &c);/*现在只能说是一元二次型方程, 因为a的值未知*/ double d = pow(b, 2) - 4 * a * c; /*d就是那个德尔塔但是没开根号*/ if (d < 0 || a == 0) /*如果a等于零那么就是一元一次方程*/ { printf("No answer!"); } else if (d >= 0) { double x1 = (0 - b + sqrt(d)) / (2 * a); double x2 = (0 - b - sqrt(d)) / (2 * a); if (x1 < x2) { printf("x1=%.5f;x2=%.5f", x1, x2); } else if (x1 > x2) { printf("x1=%.5f;x2=%.5f", x2, x1); } else if (x1 == x2) { printf("x1=x2=%.5f", x1); } } return 0; }
Information
- ID
- 6735
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- 9
- Tags
- (None)
- # Submissions
- 718
- Accepted
- 74
- Uploaded By