3.最重要的,hint也提示了要注意范围。int a 加 int b. long long c=a+b;是错的。必须a,b也为long long
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
int a = 2147483647;
int a1= 2147483648;
int b = 2147483647;
long long c = 2147483648;
long long d = a+b; //a = 0 真值的原码111111...(31个) (31个)111111111...0 原码相加 补码为10...00010,即-2
long long e=2*c;
cout<<a<<endl;
cout<<a1<<endl;
cout<<c<<endl;
cout<<d<<endl;
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
long a,b;
int m;
int aa[1000];
while(scanf("%d",&m)!=EOF&&m!=0){
int num=0;
scanf("%lld%lld",&a,&b);
long long c = a+b;
do
{
aa[num++]=c%m;
c/=m;
}while(c!=0);
for(int i=num-1;i>=0;i--){
printf("%d",aa[i]);
}
printf("\n");
}
return 0;
}