标签:break ons integer div sample simple sim ring blog
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 371689 Accepted Submission(s):
72437
1 #include<stdio.h> 2 #include<string.h> 3 int main() 4 { 5 char op1[1002],op2[1002]; 6 int c,i,j,n,m,s1[1002],s2[1002],len1,len2,count; 7 count=1; 8 scanf("%d",&n); 9 m=n; 10 while(m--) 11 { 12 memset(s1,0,1002*sizeof(int)); 13 memset(s2,0,1002*sizeof(int)); 14 scanf("%s",op1); 15 scanf("%s",op2); 16 len1=strlen(op1); 17 len2=strlen(op2); 18 c=0; 19 for(i=len1-1;i>=0;i--) 20 s1[c++]=op1[i]-‘0‘; 21 c=0; 22 for(i=len2-1;i>=0;i--) 23 s2[c++]=op2[i]-‘0‘; 24 for(i=0;i<1002;i++) 25 { 26 s1[i]+=s2[i]; 27 if(s1[i]>=10) 28 { 29 s1[i]-=10; 30 s1[i+1]++; 31 } 32 } 33 printf("Case %d:\n",count++); 34 printf("%s + %s = ",op1,op2); 35 for(i=1001;i>=0;i--) 36 if(s1[i]) 37 break; 38 for(j=i;j>=0;j--) 39 printf("%d",s1[j]); 40 printf("\n"); 41 if(count!=n+1) 42 printf("\n"); 43 } 44 return 0; 45 }
标签:break ons integer div sample simple sim ring blog
原文地址:http://www.cnblogs.com/52why/p/7478038.html