#include <stdio.h>
intmain()
{
inta, b, c, d;
longintresult, result1, result2, result3;
a = 1;
b = 2;
c = 3;
d = 4;
result1 = a + b; //在这里体验哦~
result2 = result1 * c;
result3 = result2 / d;//结果为2.25【result2为浮点型】
result = (a + b)*c / d;//结果为2【(a+b)*c为整型】
printf("%f\n", result1);
printf("%f\n", result2);
printf("%f\n", result3);
printf("%f\n", result);
return0;
}
我改了 int,longint输不出正确结果 但是float和 double可以
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/1294/viewspace-3132298/ ,如需转载,请注明出处,否则将追究法律责任。