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 |
Re:瞎提醒,这明明是水题,我来贴个代码In Reply To:瞎提醒,这明明是水题,我来贴个代码 Posted by:checkoj at 2011-02-19 12:53:36 #include <iostream> #include <stdio.h> #include <string> using namespace std; #define checkmin(a,b) if(a>b)a=b const int INF = 0x4ffffff; char str[105][105]; int len[105]; int main() { int n,i,j,k; while(scanf("%d",&n),n) { int ans=inf; for(i=1;i<=n;i++) { scanf("%s",str[i]); len[i]=strlen(str[i]); checkmin(ans,len[i]-1); } for(i=1;i<=n;i++)for(j=i+1;j<=n;j++)if(len[i]==len[j]) { for(k=len[i]-1;k>=0;k--)if(str[i][k]!=str[j][k])break; checkmin(ans,k); } printf("%d\n",ans); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator