gpt4 book ai didi

c - 如何将 10^100 的值赋给 C 中的整数变量?

转载 作者:行者123 更新时间:2023-11-30 18:15:45 26 4
gpt4 key购买 nike

我正在解决一个计算数字中位数的问题,但根据限制,数字应该在 10^100(10 的 100 次方)范围内。我已经尝试使用 limit.h 但它不起作用。谁能建议一种方法来做到这一点?

int main(){  

int n=LONG_MAX;
int count;
scanf("%d",&n);
while(n!=0)
{
n=n/10;
count++;
}
printf("%d",count);
return 0;
}

最佳答案

嗯,在 C 中,10^100 可以轻松存储到 int 中:

int xored = 10^100;

之后,xored 将存储 110。

1100100
0001010
-------
1101110

关于c - 如何将 10^100 的值赋给 C 中的整数变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44398722/

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