Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:瞎提醒,这明明是水题,我来贴个代码

Posted by huayunconglong2 at 2011-09-26 22:15:15 on Problem 3852
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator