gpt4 book ai didi

c - 奇怪的 printf 输出

转载 作者:行者123 更新时间:2023-12-04 11:35:20 27 4
gpt4 key购买 nike

<分区>

我执行了下面的代码

#include <stdio.h>

int main()
{
printf("%f\n", 9/5);
}

输出:0.000000

为什么不是1

如果我写 printf("%f %f %d %d\n", (float)9/5, 4, sizeof(float), sizeof(int));

然后输出为 1.800000 0.000000 4 59

为什么不是 1.800000 4 4 4

在我的机器上,sizeof (float)4

提前致谢

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com