Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
我去!!用EOF居然WA!!附代码!!!#include<stdio.h> #include<string.h> #include<memory.h> char str1[111],str2[222],str3[111]; char * strrev_(char *str) { int n = strlen(str); char* begin = str; char* end = str + n - 1; while (begin < end) { char tmp = *begin; *begin = *end; *end = tmp; ++begin; --end; } return str; } int main() { int N,i,j,n,m,q,p,l; scanf("%d",&N); { getchar(); p=N; while(N--) { memset(str1,'0',sizeof(str1)); memset(str2,'0',sizeof(str2)); scanf("%s %s",str1,str2); strrev_(str1); strrev_(str2); n=strlen(str1); m=strlen(str2); int max=n>m?n:m; str1[n]='0'; str2[m]='0'; int e=0; for(i=0;i<=max;i++) { if(str1[i]+str2[i]-'0'+e<='1') { str3[i]=str1[i]+str2[i]-'0'+e; e=0; } else { str3[i]=str1[i]+str2[i]-'0'+e-2; e=1; } } for(i=max;i>=0;i--) { if(str3[i]!='0') break; } str3[i+1]='\0'; int f=strlen(str3); strrev_(str3); printf("%d ",p-N); if(i==-1) printf("0\n"); else { for(i=0;i<f;i++) putchar(str3[i]); printf("\n"); } } } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator