#include
int main() { int a,b,c,d; double result; a = 1; b = 2; c = 3; d = 4; result = a+ b+ c/d; //在这里体验哦~ printf("%f\n", result); return 0; } 这样为啥输出3.000000,不是3.750000?int a,b,c,d改成float a,b,c,d
怎么修改能得到3.750000
#include<stdio.h>
int main()
{
float a,b,c,d;
double result;
a = 1;
b = 2;
c = 3;
d = 4;
result = a+ b+ c/d; //你定义的是整形,c/d结果取整,所以答案是3
printf("%f\n", result);
return 0;
}