gpt4 book ai didi

c - 为什么这个运算等于1?

转载 作者:行者123 更新时间:2023-11-30 14:59:47 25 4
gpt4 key购买 nike

#include<stdio.h>
#include<stdlib.h>

int main(){
float x;
x=4/(4-1);
printf("%f\n", x);

}

当我尝试在 c 上运行它时,它使 x 等于 1,我不明白为什么

最佳答案

因为您要对两个 int 进行除法,所以您将获得一个 int 作为结果。

关于c - 为什么这个运算等于1?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42544212/

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