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> int main() { char str[10][50]; int i,j,a=0,max=0,m,p; int len[10],sumstr[51]={0}; while(1) { gets(str[a]); if(strcmp(str[a],"0")==0)break; len[a]=strlen(str[a]); if(max<len[a])max=len[a]; a++; } for(i=0;i<a;i++) { m=max; for(j=len[i]-1;j>=0;j--) { sumstr[m]+=str[i][j]-'0'; m--; } for(j=max;j>=0;j--) { if(sumstr[j]>9) { sumstr[j-1]=sumstr[j-1]+1; sumstr[j]=sumstr[j]-10; } } } for(i=0;i<=max;i++) { if(sumstr[i]!=0) {p=i;break;} } for(i=p;i<=max;i++) printf("%d",sumstr[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