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 msi at 2007-08-01 08:38:13 on Problem 1035
我的程序在sample下没问题,但是一提交就WA
哪位能提供多一些的测试数据?
谢谢!

附程序:
#include <stdio.h>
#include <string.h>

#define TRUE 1
#define FALSE 0

char dic[10001][20];
int index;


int is_correct(char *word)
{
	int i;
	for(i=0; i<index; i++)
		if(strcmp(dic[i], word) == 0)
			return TRUE;
	return FALSE;
}

int main(void)
{
	int i, j, k, flags;
	int len_dic, len_word;
	char word[20];
	for(i=0; i<10001; i++)
	{
		scanf("%s", dic[i]);
		if(dic[i][0] == '#')
			break;
	}
	index = i;
	for(i=0; i<50; i++)
	{
		scanf("%s", word);
		if(word[0] == '#')
			break;
		if (is_correct(word) == TRUE)
		{
			printf("%s is correct\n", word);
			continue;
		}
		printf("%s:", word);
		for(j=0; j<index; j++)
		{
			len_dic = strlen(dic[j]);
			len_word = strlen(word);
			if(len_dic == len_word)
			{
				flags = 0;
				for(k=0; k<len_dic; k++)
					if(dic[j][k] != word[k])
					{
						if(flags == 1)
							break;
						flags = 1;
					}
				if(k == len_dic)
					printf(" %s", dic[j]);
			}
			else if(len_dic == (len_word+1))
			{
				k=0;
				while(k<len_word && word[k]==dic[j][k])k++;
				for(++k; k<len_dic; k++)
					if(dic[j][k] != word[k-1])
						break;
				if(k == len_dic)
					printf(" %s", dic[j]);
			}

			else if(len_word == (len_dic+1))
			{
				k=0;
				while(k<len_dic && word[k] == dic[j][k])k++;
				for(++k; k<len_word; k++)
					if(word[k] != dic[j][k-1])
						break;
				if(k == len_word)
					printf(" %s", dic[j]);
			}
		}
		printf("\n");
	}
	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