在C语言或者C++中数据都有范围
unsigned int 0~4294967295
int -2147483648~2147483647
unsigned long 0~4294967295
long -2147483648~2147483647
long long:-9223372036854775808~9223372036854775807
unsigned long long:0~18446744073709551615
#include <iostream>
using namespace std;
int main()
{
int c ;
c = 21474836471;
cout<<c;
return 0;
}
此时由于超int的数据类型范围,所以输出了乱码。
改为最大范围的unsigned long long类型就能输出
#include <iostream>
using namespace std;
int main(void)
{
unsigned long long c ;
c = 21474836471;
cout << c;
return 0;
}如果连的unsigned long long类型都超过,就只能这样了
#include <bits/stdc++.h>
using namespace std;
const int N = 9999999;
string c = "139922498948348494839893839849982938938928292";
int a[N];
int main()
{
for (int i = 0; i < c.length(); i++)
{
a[i] = c[i] - '0';
}
for (int i = 0; i < c.length(); i++)
{
cout << a[i];
}
}