int main (void)
{
Int x=0;
Int nums [11]=,3,2,1 {0};
Int I=4, j;
Int a=nums [0].
For (j=1; J & lt; i; J++)
{
If (a==0)
{
//if (x * 10 & lt; * 10-2147483648 | | x & gt; 2147483647 | | x * 10 + nums [j] <- 2147483648 | | x * 10 + nums [j] & gt; 2147483647)
If (x * 10 & gt; 2147483647 | | x * 10 + nums [j] & gt; 2147483647)
//return 0;
return 0;
}
//else if (nums [0]==1)//handling of negative
If (a==1)//handling of negative
{
//if (0 - (x * 10) & lt; - 2147483648 | | 0 - (x * 10) & gt; 2147483647 | | 0 - (x * 10 + nums [j]) & lt; - 2147483648 | | 0 - (x * 10 + nums [j]) & gt; 2147483647)
If (0 - (x * 10) & lt; - 2147483648 | | 0 - (x * 10 + nums [j]) & lt; - 2147483648)
return 0;
}
//if (a==0)
//{
//if (x * 10 & gt; 2147483647 l | | x * 10 + nums [j] & gt; 2147483647 l)
//return 0;
//}
X=x * 10 + nums [j];
}
Printf (" % d \ n ", x);
return 0;
}
A weird question is, the program will skip two if statements in the for loop, the last statement in the direct execution cycle, this is how to return a responsibility?
O great god answer
CodePudding user response:
X * 10 & gt; 2147483647 | | x * 10 + nums [j] & gt; 2147483647Such a statement is true forever, because int never greater than INT32_MAX, if the calculation result is greater than the INT32_MAX, will be back,
CodePudding user response:
It is wrong, should be always falseCodePudding user response:
A=num [0], which is 0, no modified behind a, so under a==1, do not perform this procedure,CodePudding user response:
This have what strange, likeYou made the earth longitude and latitude of their location, and then write a if
Said that if in the east of the east longitude 180 degrees, or on the west side of west longitude 180 degrees or 90 degrees north latitude north, or 90 degrees south latitude to the south, then outputs an error message,
Is this nonsense? The natural is damaged,
As same reason,
CodePudding user response:
Computer mathematics not human, it is just a rough approximation,This is the current computer architecture can't for the birth of a true artificial intelligence philosophy of reason,
CodePudding user response:
Input, if beyond the scope of int, will rollback, you can use the long long type, if not out of scope, then converted to intCodePudding user response:
Or in the form of a string of judgmentCodePudding user response: