| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
有兴趣的帮忙看看代码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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator