每当我尝试运行它时,它都会返回错误的解决方案,例如:
A:303
B:405
C:50
真正的解决方案:-0.13762776465722773
我的解决方案:-110079.531250
#include <stdio.h>
#include <math.h>
int main(){
float a;
float b;
float c;
float solution;
float d;
printf("A: ");
scanf("%f", &a);
printf("B: ");
scanf("%f", &b);
printf("C: ");
scanf("%f",&c);
d = b * b - 4 * a * c;
solution = (-b - sqrt(d))/ 2*a;
printf("%f", solution);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
210 次 |
| 最近记录: |