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 ferrettemp at 2005-02-15 00:46:16 on Problem 1677
In Reply To:我也无言了 Posted by:ferrettemp at 2005-02-15 00:45:14
#include <stdio.h>
int compare(char *one,char *two)
{
	int i=0;
	while (one[i]==two[i]&&one[i]!='\0')
		i++;
	return one[i]-two[i];
}
void main()
{
	char name[5][31],s[201],temp[31];
	char key[3][10]={"beautiful","pretty","lovely"};
	int i,j,k,m,n,wordnum,biaozhi,ok,t,namesign[5];
	scanf("%d%d",&n,&m);
	for (i=0;i<n;i++)
		scanf("%s",name[i]);
	getchar();
	for (t=0;t<m&&gets(s)!=0;t++)
	{
		for (i=0;i<n;i++)
			namesign[i]=0;
		biaozhi=i=wordnum=0;
		while (1)
		{
	while (s[i]!='\0'&&!(s[i]>='A'&&s[i]<='Z'||s[i]>='a'&&s[i]<='z'))
				i++;
			if (s[i]=='\0')
				break;
			k=0;
		while (s[i]>='A'&&s[i]<='Z'||s[i]>='a'&&s[i]<='z')
			{
				if (s[i]>='A'&&s[i]<='Z')
					temp[k]=s[i]+32;
				else temp[k]=s[i];
				i++,k++;
			}
			temp[k]='\0';
			wordnum++;
			for (j=0;j<n;j++)
				if (compare(temp,name[j])==0)
				{
					namesign[j]=1;
					break;
				}
			if (j==n&&biaozhi==0)
			{
				for (j=0;j<3;j++)
					if (compare(temp,key[j])==0)
					{
						biaozhi=1;
						break;
					}
			}
		}
		ok=1;
		for (i=0;i<n;i++)
			if (namesign[i]==1)
			{
				if (ok==1)
				{
					printf("%s",name[i]);
					ok++;
				}
				else printf(" %s",name[i]);
			}
		if (ok==1)
			printf("All");
		printf(": ");
		if (wordnum<10)
			printf("oh\n");
		else if (biaozhi==1)
			printf("xixi\n");
		else printf("hehe\n");
	}
}

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