69,373
社区成员
发帖
与我相关
我的任务
分享
int main(void)
{
int x=0;
int nums[11]={0,3,2,1};
int i=4,j;
int a=nums[0];
for (j = 1; j < i; j++)
{
if (a == 0)
{
//if(x*10<-2147483648 || x*10>2147483647 || x*10+nums[j]<-2147483648 || x*10+nums[j]>2147483647)
if (x * 10 > 2147483647 || x * 10 + nums[j] > 2147483647)
//return 0;
return 0;
}
//else if (nums[0] == 1) //对负数的处理
if (a == 1) //对负数的处理
{
//if(0-(x*10)<-2147483648 || 0-(x*10)>2147483647 || 0-(x*10+nums[j])<-2147483648 || 0-(x*10+nums[j])>2147483647)
if (0 - (x * 10) < -2147483648 || 0 - (x * 10 + nums[j]) < -2147483648)
return 0;
}
//if(a==0)
//{
// if (x * 10 > 2147483647L || x * 10 + nums[j] > 2147483647L)
// return 0;
//}
x = x * 10 + nums[j];
}
printf("%d\n",x);
return 0;
}
if (a == 0)
{
printf("a==0\n");//这里加一句输出不就清楚了?
//if(x*10<-2147483648 || x*10>2147483647 || x*10+nums[j]<-2147483648 || x*10+nums[j]>2147483647)
if (x * 10 > 2147483647 || x * 10 + nums[j] > 2147483647)
//return 0;
return 0;
}