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

疯了~~ 就是不过~~WHY?

Posted by tongkang at 2009-04-19 09:32:19 on Problem 1677
#include<iostream>
#include<string>
using namespace std;
char wish[230];
string name[5];
string tmp;
int girl[5]={0};
int g,w,word,all=1,flag=0;
void fun(void);
void print(void);
int  main(void)
{
    int i,j;
    tmp="";
    scanf("%d %d",&g,&w);
    for(i=0;i<g;i++)
    {
        cin>>name[i];
    }
    getchar();
    for(i=0;i<w;i++)
    {
            flag=0;
            memset(girl,0,sizeof(girl));
            word=0;
            tmp="";
            cin.getline(wish,sizeof(wish));
            int len=strlen(wish);
            for(j=0;j<len;j++)
            {
                if(wish[j]==' '||wish[j]=='!')
                {
                        if(tmp!=""&&wish[j-1]!='!')
                        {
                                fun();
                                word++;
                        }
                        tmp="";
                }
                else if (wish[j]>= 'A'&&wish[j]<='Z')
                {
                    tmp+=wish[j]+'a'-'A';
                }
                else
                {
                    tmp+=wish[j];
                }
            }
            print();
    }
    return 0;
}
void fun(void)
{
    for(int i=0;i<g;i++)
    {
            if(tmp.compare(name[i])==0)
            {
                all=0;
                girl[i]=1;
            }
    }
    if(tmp.compare("beautiful")==0||tmp.compare("pretty")==0||tmp.compare("lovely")==0)
        flag=1;
}
void print(void)
{
    bool first=1;
    if(all)
    {
        printf("All");
    }
    else
    {
        for(int i=0;i<g;i++)
        {
                if(girl[i])
                {
                    if(first)first=0;
                    else cout<<" ";
                    cout<<name[i];
                }
        }
    }
    cout<<": ";
    if(word<=9)cout<<"oh"<<endl;
	else if(word>9&&flag==1) cout<<"xixi"<<endl;
	else if(word>9&&flag==0) cout<<"hehe"<<endl;
}

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