#include<stdio.h>
#include<string.h>
main(){
char s[1001],a[1001];
int i,n,max=0;
for(i=0;i<1001;i++) a[i]=0;
while(scanf("%s",s)==1){
if(!strcmp(s,"0")) break;
n=strlen(s);
if(n>max) max=n;
for(i=0;i<n;i++){
a[i]+=s[n-i-1]-'0';
}
}
for(i=0;i<max;i++){
if(a[i]>=10){
if(i==max-1) max++;
a[i+1]+=a[i]/10;
a[i]%=10;
}
}
for(i=max-1;i>=0;i--) printf("%c",a[i]+'0');
printf("\n");
scanf(" ");
}
我用printf("%d",(int)a[i])跑過,發現值都是負的