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> typedef struct { char a[110]; int l; }ad; int zm(char s1[],char s2[],int i,int j)//顺序匹配 { int cd=0,l1=strlen(s1),l2=strlen(s2); if(s2[j]!=s1) return 0; while(j<l2&&i<l1) { if(s2[j]==s1) { i++; j++; cd++; } else break; } return cd; } int nm(char s1[],char s2[],int i,int j)//逆序匹配 { int cd=0,l1=strlen(s1),l2=strlen(s2); if(s2[j]!=s1) return 0; while(j>=0&&i<l1) { if(s2[j]==s1) { j--; i++; cd++; } else break; } return cd; } int main() { int t,i,j,k,n,ml,id,s,c[110],ma,m,q,d[110]; ad b[110]; scanf("%d",&t); while(t--) { scanf("%d",&n); getchar(); ml=110;s=0;/*找最小长度的字符串 for(i=0;i<n;i++) { gets(b.a); b.l=strlen(b.a); if(b.l<ml) { ml=b.l; id=i; } }*/ for(j=0;j<b[id].l;j++)//取要匹配的字符串的第一个字符 { c[j]=200; for(k=0;k<n;k++) { d[k]=180;q=0; if(k!=id) {/*取顺序,逆序匹配的最大长度 for(m=0;m<b[k].l;m++) if(zm(b[id].a,b[k].a,j,m)>q) q=zm(b[id].a,b[k].a,j,m); for(m=b[k].l-1;m>=0;m--) if(nm(b[id].a,b[k].a,j,m)>q) q=nm(b[id].a,b[k].a,j,m); d[k]=q; }*/ else d[k]=150; if(d[k]<c[j]) c[j]=d[k]; } } ma=0; for(j=0;j<b[id].l;j++) { if(c[j]>ma) ma=c[j]; } printf("%d\n",ma); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator