在C中,当我移动此printf行时:printf("%f\n", 5 / 2);对于不同的行,其输出会发生变化.有任何想法吗?
下面是代码:
#include <stdlib.h>
#include <stdio.h>
int main()
{
int a = 65;
char c = (char)a;
int m = 3.0/2;
printf("%c\n", c);
printf("%f\n", (float)a);
printf("%f\n", 5.0 / 2);
printf("%f\n", 5 / 2.0);
printf("%f\n", (float)5 / 2);
printf("%f\n", 5 / (float)2);
printf("%f\n", (float)(5 / 2));
printf("%f\n", 5.0 / 2);
printf("%d\n", m);
printf("%f\n", 5 / 2);
system("PAUSE");
return(0);
}
Run Code Online (Sandbox Code Playgroud)
继承人的产量:
A
65.000000
2.500000
2.500000
2.500000
2.500000
2.000000
2.500000
1
2.500000
Run Code Online (Sandbox Code Playgroud)
如果我移动printf("%f\n", 5 / 2);到第一行之一(在输出A的那一行和输出65.000000的那一行之间),它将打印0.000000(这是有意义的)而不是现在的2.500000.有任何想法吗?