注意事项:
当进行置换时,for(int i=0;i
参考代码:#include
using namespace std;
int a[105];
int b[105];
int c[105];
int main(){
int i=0,len1,len2,j=0;
char ch;
int temp;
while((ch=getchar())!='\n'){
temp=ch-'0';
a[i]=temp;
i++;
}
len1=i;
//将个位置到前面,进行交换
for(int i=0;i
temp=a[i];
a[i]=a[len1-1-i];
a[len1-1-i]=temp;
}
i=0;
while((ch=getchar())!='\n'){
temp=ch-'0';
b[i]=temp;
i++;
}
len2=i;
//将个位置到前面,进行交换
for(int i=0;i
temp=b[i];
b[i]=b[len2-1-i];
b[len2-1-i]=temp;
}
//加法
int s=0;
for(int i=0;i<105;i++){
s=a[i]+b[i]+s;
c[i]=s%10;
s=s/10;
}
for(int i=105;i>=0;i--){
if(c[i]!=0){
for(int k=i;k>=0;k--){
printf("%d",c[k]);
}
break;
}
}
printf("\n");
return 0;
}