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

这!C能过,GCC就过不了!附代码!

Posted by woshiliyiyiyiyi at 2012-07-31 17:06:02 on Problem 1750
#include<stdio.h>
#include<string.h>
#define N 100001

int KMP(char a[], char b[])
{
	int k1, k2, i;
	int count;

	k1 = strlen(a);
	k2 = strlen(b);
	count = 0;
	for (i=0; i<k1&&i<k2; i++)
	{
		if (a[i] == b[i])
		{
			count++;
		}
		else
		{
			break;
		}
	}

	return count;
}

int main()
{
	char str[N][12];
	int i, k, p;
	int count;

	fscanf(stdin, "%s", str[0]);
	printf("%s\n", str[0]);
	i = 1;
	count = 0;
	while (fscanf(stdin, "%s", str[i]) != EOF)
	{
		k = KMP(str[i], str[i-1]);
		if (k > count)
		{
			count++;
		}
		else
		{
			count = k;
		}
		for (p=0; p<count; p++)
			printf(" ");
		printf("%s\n", str[i]);
		i++;
	}

	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