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 |
疯了~~ 就是不过~~WHY?#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator