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 |
彻底崩溃!!!!!!!!!#include<stdio.h> #include<string.h> void main() { int i,t,j=0,k,m,n,num=0,x,result[102]; char a[102],b[102]; scanf("%d",&n);getchar(); while(n--) { num++;x=0; for(i=0;i<102;i++) result[i]=0; if(scanf("%s %s",a,b)==2){ k=strlen(a);m=strlen(b); if(k>m){ for(i=k-1,t=0;i>=0;i--,t++) { result[t]+=(a[i]-'0'); if(result[t]>=2) { result[t]=result[t]-2; result[t+1]+=1; } } m=(m>=k?k:m); for(i=m-1,t=0;i>=0;i--,t++) { result[t]+=(b[i]-'0'); if(result[t]>=2) { result[t]=result[t]-2; result[t+1]+=1; } } m=(m>=k?m:k); for(i=m-1,t=0;i>=0;i--,t++) if(result[t]>=2) { result[t]=result[t]-2; result[t+1]+=1; } } else{ for(i=m-1,t=0;i>=0;i--,t++) { result[t]+=(b[i]-'0'); if(result[t]>=2) { result[t]=result[t]-2; result[t+1]+=1; } } for(i=k-1,t=0;i>=0;i--,t++) { result[t]+=(a[i]-'0'); if(result[t]>=2) { result[t]=result[t]-2; result[t+1]+=1; } } m=(m>=k?m:k); for(i=m-1,t=0;i>=0;i--,t++) if(result[t]>=2) { result[t]=result[t]-2; result[t+1]+=1; } } for(i=101;i>=0;i--)if(result[i]!=0){x=i;break;} printf("%d ",num); if(x==0)printf("0"); else for(;x>=0;x--)printf("%d",result[x]); printf("\n");} } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator