Girls' Day

PKU.1677

Description
On Girls' Day (Haven't heard about it? Well, you may ask the author for details...), we boys get together with girls in the class. On the occasion, every boy will make a wish for girls. Boys want to know about girls' responses to their wishes.
If a wish contains one or more girls' names, it is considered to be talking to them specifically. Otherwise it is talking to all the girls. A wish can simultaneously talk to several girls of course.
A girl would say 'oh' if the wish contains at most 9 words.
A girl would say 'xixi' if the wish contains at least 10 words and she hears the word 'beautiful', 'pretty' or 'lovely'.
A girl would say 'hehe' if the wish contains at least 10 words and she doesn't hear such words mentioned above.
It is confirmed that a wish will not contain all the girls? name.

Input
The first line of the input contains two integers g and w (1 <= g <= 5, 1 <= w <= 30), the number of girls and the number of wishes respectively. The next g lines each contain a word in lowercase, representing the name of a girl. Then the next w lines each contain a string of letters and punctuations, namely the wish, which will contain at most 200 characters.
Each wish contains one or more sentences, and each sentence is terminated by a '!'. The first letter of each sentence is in uppercase, and other letters will be always in lowercase. No other characters apart from '!', spaces and letters will appear in the sentence. You may assume that each wish is correct in grammar.

Output
You are required to give girls' response according to the input. For each wish, if it is talking to all the girls, print 'All', or otherwise print the list of girls that it is talking to (names are separated by a single space) in the order that they appear in the name list. Then print a semicolon followed by a space, and the response such as 'hehe' and 'xixi'.

Sample Input
5 5
answer
baiqingr
cedar
juleo
seven
Happy girls day to all of you!
Happy girls day to all of you!Wish you happy forever!
Happy girls day for answer mm!
Congratulations for cedar mm and seven mm!Wish you more and more beautiful hehe!
Hello answer hello baiqingr hello juleo would you mind having dinner together!

Sample Output
All: oh
All: hehe
answer: oh
cedar seven: xixi
answer baiqingr juleo: hehe

Source

My Program

#include < iostream >
#include
< string .h >
using   namespace  std;

int  main()
{
    
char name[5][201],*word,wish[201];
    
bool girl[5],out,good;
    
int g,w,i,j,m;
    cin
>>g>>w;
    
for(i=0;i<g;i++)
        cin
>>name[i];
    getchar();
    
for(i=0;i<w;i++)
    
{
        gets(wish);m
=0;
        memset(girl,
false,sizeof(girl));
        good
=out=false;
        for(j=0;wish[j]!='/0';j++)
            
if(wish[j]>='A'&&wish[j]<='Z')
                wish[j]
-='A'-'a';
        word
=strtok(wish," !");
        
while(word)
        
{
            m
++;
            
if(!good&&(!strcmp(word,"beautiful")||!strcmp(word,"pretty")||!strcmp(word,"lovely")))
                good
=true;
            
for(j=0;j<g;j++)
                
if(!strcmp(word,name[j]))
                
{
                    girl[j]
=true;
                    
break;
                }

            word
=strtok(NULL," !");
        }

        
for(j=0;j<g;j++)
            
if(girl[j]==true)
                
if(out==true)
                    cout
<<" "<<name[j];
                
else
                
{
                    cout
<<name[j];out=true;
                }

        
if(out==false)
            cout
<<"All";
        cout
<<"";
        
if(m<10)
            cout
<<"oh";
        
else
            
if(good)
                cout
<<"xixi";
            
else
                cout
<<"hehe";
        cout
<<endl;
    }

    
return 0;
}

YOYO's Note:
┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄它是华丽的分隔线

【题意简述】

女生节到了,你将对g个女孩子说w句话,并计算她们的反应。


【粗略分析】

输入字符,
用strtok分割掉关键词' '/'!'即可……
边计算单词,与名字、特殊词匹配
最后输出

【C++源代码】

#include < iostream >
#include
< string .h >
using   namespace  std;

int  main()
{
    
char name[5][201],*word,wish[201];
    
bool girl[5],out,good;
    
int g,w,i,j,m;
    cin
>>g>>w;
    
for(i=0;i<g;i++)
        cin
>>name[i];
    getchar();
    
for(i=0;i<w;i++)
    
{
        gets(wish);m
=0;
        memset(girl,
false,sizeof(girl));
        good
=out=false;
        for(j=0;wish[j]!='/0';j++)
            
if(wish[j]>='A'&&wish[j]<='Z')
                wish[j]
-='A'-'a';
        word
=strtok(wish," !");
        
while(word)
        
{
            m
++;
            
if(!good&&(!strcmp(word,"beautiful")||!strcmp(word,"pretty")||!strcmp(word,"lovely")))
                good
=true;
            
for(j=0;j<g;j++)
                
if(!strcmp(word,name[j]))
                
{
                    girl[j]
=true;
                    
break;
                }

            word
=strtok(NULL," !");
        }

        
for(j=0;j<g;j++)
            
if(girl[j]==true)
                
if(out==true)
                    cout
<<" "<<name[j];
                
else
                
{
                    cout
<<name[j];out=true;
                }

        
if(out==false)
            cout
<<"All";
        cout
<<"";
        
if(m<10)
            cout
<<"oh";
        
else
            
if(good)
                cout
<<"xixi";
            
else
                cout
<<"hehe";
        cout
<<endl;
    }

    
return 0;
}

【注意事项】

※ 如果没有指名对任何人祝福的话则是对所有人祝福。
※ 可能含有连续的多个"     "或"!!!"等。

【点评】

才会用strtok……

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值