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 |
真是奇葩啊,用C能过....#include <stdio.h> #include <string.h> int main() { char s1[50],s2[50]; int len1,len2; int blank=0; int i,sum,flag; scanf("%s",s1); printf("%s\n",s1); while(scanf("%s",s2)!=EOF) { len1=strlen(s1); len2=strlen(s2); sum=0; flag=1; for(i=0;i<len1&&i<len2;i++) { if(s1[i]==s2[i]) sum++; else break; if(sum>blank) { flag=0; blank++; break; } } if(flag) blank=sum; for(i=0;i<blank;i++) printf(" "); printf("%s\n",s2); strcpy(s1,s2); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator