1直接计算
int maxint = static_cast<int>(pow(2,8*sizeof(int)-1)-1);
//pow计算结果是double型,计算最大整数时不至于溢出
2循环
int maxint=1;
int temp=maxint;
while(temp>0){
maxint = temp;
temp = temp*2+1;
}
1直接计算
int maxint = static_cast<int>(pow(2,8*sizeof(int)-1)-1);
//pow计算结果是double型,计算最大整数时不至于溢出
2循环
int maxint=1;
int temp=maxint;
while(temp>0){
maxint = temp;
temp = temp*2+1;
}