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

wa成傻B了,有人知道为什么吗?

Posted by 2012xie at 2013-02-06 09:46:32 on Problem 1677
#include<stdio.h>
#include<string.h>
int g,w;
char s[250];
char tmp[100];
char girl[6][30];
int to_who[10];
int flag,count;
void fun()
{
    int i,j,k,jilu;
    memset(to_who,-1,sizeof(to_who));
    k=flag=count=0;
    flag=0;
    for(i=0; s[i]; i++)
    {
        memset(tmp,0,sizeof(tmp));
        j=jilu=0;
        while(('a'<=s[i]&&s[i]<='z')||('A'<=s[i]&&s[i]<='Z'))
        {
            jilu=1;
            if(s[i]>='a'&&s[i]<='z')
                tmp[j++]=s[i++];
            else
                tmp[j++]=s[i++]-'A'+'a';
        }
        if(jilu)count++;
        for(j=0; j<g; j++)
            if(strcmp(girl[j],tmp)==0)
            {
                to_who[k++]=j;
            }
        if(strcmp(tmp,"beautiful")==0||strcmp(tmp,"pretty")==0||strcmp(tmp,"lovely")==0)
            flag=1;
    }
}
int main()
{
    freopen("input.txt","r",stdin);
    int i,j;
    while(scanf("%d%d",&g,&w)!=EOF)
    {
        for(i=0; i<g; i++)
            scanf("%s",girl[i]);
        getchar();
        while(w--)
        {
            gets(s);
            fun();
            if(to_who[0]==-1)
                printf("All");
            else
            {
                printf("%s",girl[to_who[0]]);
                i=1;
                while(to_who[i]!=-1)
                {
                    printf(" %s",girl[to_who[i]]);
                    i++;
                }
            }
            printf(": ");
            if(count<=9)
                printf("oh\n");
            else if(flag==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