[問題] printf變數型態問題
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
GCC
問題(Question):
#include <stdio.h>
int main(void) {
int a=5;
float b=5;
printf("%f\t%d\n", a/2,a/2);
printf("%f\n",a/2);
printf("%d\n"a/2);
printf("%f\t%d\n", b/2,b/2);
printf("%f\n",b/2);
printf("%d\n",b/2);
}
(1)為什麼發亮的地方是0???
(2)為什麼順序的不同會造成結果不同??
[output]
0.000000 4199093(亂數)
0.000000
2
2.500000 0
2.500000
0
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 111.243.165.67
→
07/04 23:40, , 1F
07/04 23:40, 1F
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 1 之 2 篇):