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 |
不会出现空格吧In Reply To:帮我看看这个简单题,怎么会WA? Posted by:sunmoonstar_love at 2005-07-17 20:11:48 > #include <stdio.h> > #include <string.h> > int n,i,lenc,lenl,res,tmp; > char last[300],curr[300]; > int bit(int a) > { > int ans = 1; > while(a>=10) > { > ans++; > a = a/10; > } > return ans; > } > int main() > { > scanf("%d",&n); > res = 0; > scanf("%s",last); > if(n==1) > { > printf("%d\n",strlen(last)); > return 0; > } > res += (lenl=strlen(last)); > n--; > while(n--) > { > scanf("%s",curr); > lenc = strlen(curr); > tmp = lenc>lenl?lenl:lenc; > for(i=0; i<tmp; i++) > if(last[i]!=curr[i]) > break; > res += lenc - i + bit(i); > lenl = lenc; > strcpy(last,curr); > } > printf("%d\n",res); > // scanf("\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