gpt4 book ai didi

c++ - 奇怪的 "unsigned long long int"行为

转载 作者:可可西里 更新时间:2023-11-01 18:28:46 28 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
How do you printf an unsigned long long int?

#include <cstdio>

int main ()
{
unsigned long long int n;
scanf("%llu",&n);
printf("n: %llu\n",n);
n /= 3;
printf("n/3: %llu\n",n);
return 0;
}

无论我输入什么,我都会得到非常奇怪的输出,例如:

n: 1
n/3: 2863311531

n: 2
n/3: 2863311531

n: 1000
n/3: 2863311864

这是什么原因?我应该如何正确执行此操作?

(g++ 3.4.2, Win XP)

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