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:就因为这个我得了两次RE,这题也不给一个范围,服了!

Posted by win1611 at 2010-01-20 11:00:27 on Problem 2872
In Reply To:就因为这个我得了两次RE,这题也不给一个范围,服了! Posted by:hheq121 at 2008-09-19 17:15:15
为什么我这总是RE呢??? 哪位大牛能帮我看看??
#include<stdio.h>
#include<string.h>

int N,M;                //字典中共有N个单词   M封信
char arr[20][20];       //存储dictionary中的单词

int Compare(char letter[])
{
	int i;
	for(i=0;i<N;i++)
		if(strcmp(letter,arr[i])==0)
			break;
	if(i>=N)
		return 1;
	return 0;
}
int main()
{
	int i=0,j=0,flag,t,num,Eap;
	char letter[20][20];
	char wrong[20][20];             //用来记录错误单词的数组
	scanf("%d",&N);
	while(i<N)
		scanf("%s",arr[i++]);
	scanf("%d",&M);
	while(j<M)
	{
		t=0;
		num=0;
		Eap=0;
		memset(wrong[j],'0',sizeof(wrong[j]));
		while(scanf("%s",letter[t])&&strcmp(letter[t],"-1")!=0) //此时要注意&&前后两者的运行顺序
		{
			flag=Compare(letter[t]);  //若此时的flag为1的话则此单词与字典中的单词不同
			if(flag==1)
			{
				strcpy(wrong[num++],letter[t]);
				flag=0;
				Eap=1;                //此时用来标志着存在错误的单词
			}
			t++;
		}
		if(Eap)
		{
			printf("Email %d is not spelled correctly.\n",j+1);
			for(i=0;i<num;i++)
				printf("%s\n",wrong[i]);
		}
		else
			printf("Email %d is spelled correctly.\n",j+1);
		j++;
	}
	printf("End of Output\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