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可以,c++就不行,while(cin)就超时,while(scanf)就能过#include<stdio.h> #include<string.h> #define N 11 int main() { char s[N],p[N]; int t,i; t=0; strcpy(p,"-1"); while(scanf("%s",s)!=EOF) { for(i=0;i<t+1&&i<strlen(s)&&i<strlen(p);i++) if(s[i]!=p[i])break; t=i; for(i=0;i<t;i++) printf(" "); printf("%s\n",s); strcpy(p,s); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator