2条回答 默认 最新
- -Undefined_ 2021-11-20 15:00关注
#include<stdio.h> #include<math.h> int main() { double a, b, c, d, x1, x2; scanf("%lf %lf %lf", &a, &b, &c); d = b * b - 4 * a * c; if(d == 0) { x1 = (-b) / (2 * a); printf("x1=x2=%.5lf", x1); } else if(d > 0) { x1 = (-b + sqrt(d)) / (2 * a); x2 = (-b - sqrt(d)) / (2 * a); printf("x1=%.5lf;x2=%.5lf", x1,x2); } else { printf("no solution"); } return 0; }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报