ZOJ1292

没考虑以0开头的非零数了~~~汗~~~

 

 

 

 //2514353 2011-04-28 13:22:59 Wrong Answer 1292 C 0 160 ylwh! //2514357 2011-04-28 13:26:19 Wrong Answer 1292 C 0 160 ylwh! //2514365 2011-04-28 13:40:24 Wrong Answer 1292 C 0 160 ylwh! //2514503 2011-04-28 15:52:33 Accepted 1292 C 0 160 ylwh! #include <stdio.h> #include <string.h> void fanzhuan(char s[110]) { int i, j; char temp; for(i=0, j=strlen(s)-1; i<j; i++, j--) { temp=s[i]; s[i]=s[j]; s[j]=temp; } } int main(void) { int t, i, j,temp,l; int n; char s[110], sum[110]; scanf("%d", &t); while(t--) { memset(sum, '0', sizeof(s)); sum[109]='/0'; while(scanf("%s", s)!=EOF) { temp=0; l=strlen(s); if(l==1 && s[0]=='0')break; fanzhuan(s); for(i=0; i<l; i++) { n=sum[i]+s[i]-2*'0'+temp; temp=n/10; sum[i]=n%10+'0'; } for(i=l; i<110; i++) { if(temp==0) { break; } n=sum[i]+temp-'0'; temp=n/10; sum[i]=n%10+'0'; } } for(i=108;; i--) { if(sum[i]=='0') sum[i]='/0'; else break; } fanzhuan(sum); printf("%s/n", sum); if(t)printf("/n"); } return 0;吗

你可能感兴趣的:(c)