gpt4 book ai didi

c - 理解 C 双格式化程序占位符

转载 作者:太空宇宙 更新时间:2023-11-04 00:44:44 24 4
gpt4 key购买 nike

<分区>

#include <stdio.h>
int main() {
double x = 10.4, y;
int m = 2;
y = x / m;

printf("%.1f\n", y);//5.2
printf("%.1f\n", (double)(7 / 2)); //3.0, why not 3.5 ?
printf("%.1f\n", 3.5f);//3.5
// the last line prints 3.5,
// why its not rounding down to 3.0 ,as it did above ?
}

谁能解释一下这里发生了什么?

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