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 |
有那位朋友帮我测试一下,好多情况都考虑了,可还是wa#include"stdio.h" #include"string.h" void main() { char line[1000]; int out[1200]={0},i,j,lenght,cin=0,sum,max=0; while(scanf("%s",line)>0) { if(strcmp(line,"0")==0) { for(i=max-1;i>=0;i--) { printf("%d",out[i]); } printf("\n"); } lenght=strlen(line); j=0; for(i=lenght-1;i>=0;i--) { if(line[i]=='0') { sum=cin+out[j]; out[j]=(sum)%10; cin=(sum)/10; } if(line[i]=='1') { sum=cin+out[j]+1; out[j]=(sum)%10; cin=(sum)/10; } if(line[i]=='2') { sum=cin+out[j]+2; out[j]=(sum)%10; cin=(sum)/10; } if(line[i]=='3') { sum=cin+out[j]+3; out[j]=(sum)%10; cin=(sum)/10; } if(line[i]=='4') { sum=cin+out[j]+4; out[j]=(sum)%10; cin=(sum)/10; } if(line[i]=='5') { sum=cin+out[j]+5; out[j]=(sum)%10; cin=(sum)/10; } if(line[i]=='6') { sum=cin+out[j]+6; out[j]=(sum)%10; cin=(sum)/10; } if(line[i]=='7') { sum=cin+out[j]+7; out[j]=(sum)%10; cin=(sum)/10; } if(line[i]=='8') { sum=cin+out[j]+8; out[j]=(sum)%10; cin=(sum)/10; } if(line[i]=='9') { sum=cin+out[j]+9; out[j]=(sum)%10; cin=(sum)/10; } j++; } for(i=lenght;cin!=0;i++) { out[i]=(cin+out[i])%10; cin=(cin+out[i])/10; lenght++; } if(max<lenght) max=lenght; } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator