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 啊 Wa 啊>_<,路过的大牛求指教#include<stdio.h> #include <string.h> int main() { int m; char str[4005][205],a[205],b[205]; int i,j,len,num,tmp,k,t,l1=255,pos; while(scanf("%d",&m)!=EOF) { num=0; if(m==0) break; for(i=0;i<m;i++) { scanf("%s",str[i]); len=strlen(str[i]); if(len<l1) { l1=len; pos=i; } } for(i=1;i<=l1;i++) { for(j=0;j+i-1<l1;j++) { for(k=0;k<i;k++) { a[k]=str[0][j+k]; } a[k]='\0'; for(k=0;k<m;k++) { if(strstr(str[k],a)==NULL) break; } if(k>=m) { tmp=strlen(a); if(tmp==num) { for(t=0;t<num;t++) { if(a[t]<b[t]) { for(t=0;t<=num;t++) b[t]=a[t]; break; } } } if(tmp>num) { num=tmp; for(t=0;t<=num;t++) { b[t]=a[t]; } } } } } if(num>=1) printf("%s\n",b); else printf("IDENTITY LOST\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