Home > Back-end >  Help!!!!!! Problem A: another version B A 50% error
Help!!!!!! Problem A: another version B A 50% error

Time:11-19

 although not regular routines: no problem, but I feel I wrote but I don't know where is wrong

CodePudding user response:

# include & lt; Iostream>

using namespace std;
Int main ()
{
Int j, A, B;
Int ans [32].
Int c1=0, num;
Int temp=0;
While (the scanf (" % d ", & amp; M), m)
{
The scanf (" % d % d ", & amp; A, & amp; B);
Ans [32]={0};
num=0;
Do
{
Temp=A % m + B % m + c1;
Ans [num++]=temp % m;
C1=temp/m;
A/m=;
B/m=;
} while ((A!=0 & amp; & B!=0) | | c1!=0);
For (int I=num 1; I>=0; I -)
{
Printf (" % d ", ans [I]);
}
printf("\n");
}
return 0;
}

CodePudding user response:

You did not consider beyond int
the condition of the

CodePudding user response:

2147483647 + 2147483647
2147483647 is not 2 ^ 31-1

CodePudding user response:

What is the title?

CodePudding user response:

The
reference 3 floor qq_42760500 response:
2147483647 + 2147483647
2147483647 is not 2 ^ 31-1

But 2147483647 is 2 ^ 31-1, 2147483647 + 2147483647=2 ^ 32-2, exceeded the scope of int,
In addition, you here only 2 base and eight into the system, if it is a hexadecimal, missing a - f conversion processing,
, of course, don't know what you want the original, here just for you and the possibility of speculation, still need to make the topic request to describe,
  • Related