C++中存储超过32位的大整数,并且需要对其进行取余操作,该怎么设计?
ringa_lee
ringa_lee 2017-04-17 14:58:43
0
4
605

在做一个习题,要求如下:

我在数字比较小时已经解决了这个问题,可是当整数达到30位时,long long int 已经不能存储,请问有什么解决方法吗?

我自己写的程序详见 https://github.com/huyang7211...

欢迎大家一起来刷题

ringa_lee
ringa_lee

ringa_lee

reply all(4)
小葫芦

Using character array processing can increase flexibility;
eg:

char chArr[32] = "12345678912345678912345678912345";//你可以使用比较大的长度
int i = 0, sum = 0;
for(; i < 32; i++)
{
    sum += chArr[i] - '0';
}
迷茫

用char array

刘奇

You don’t actually need to store the number itself...

迷茫

If it were me, I would treat this number as a string.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template