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

小弟一共做了两个题,实在不行了,求高手指教

Posted by a16891e at 2012-10-03 20:10:28 on Problem 2406
#include<stdio.h>//求公共子串
int main()
{
	char a[1000]={0},b[1000]={0};
	int m=-1,n=0,i=0,j=0;
	scanf("%s",&a);
	while(1)
	{
		m=-1;
		n=0;
		i=0;
		j=0;
		for(i=0;i<1000000&&a[i]!=0;i++)
		{
			if(m==-1)
			{
				b[0]=a[0];
				m=0;
				continue;
			}
			if(n>m)
			{
				n=0;
			}
			if(a[i]!=b[n])
			{
				for(j=0;j<=i;j++)
				{
						b[j]=a[j];
				}
				n=0;
				m=i;
				continue;
			}
			n++;
		}	
		if(n!=m+1)
		{	
			printf("%d",1);
			scanf("%s",&a);
			continue;
		}
		printf("%d",i/(m+1));
		scanf("%s",&a);
	}
	return 0;
}

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