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 |
贴一段AC代码#include<stdio.h> #include<string.h> #include<iostream> using namespace std; char girl[8][256]; int gx[8]; char wish[32][256]; char beautiful[]="beautiful"; char pretty[]="pretty"; char lovely[]="lovely"; int main() { int g,m; while(~scanf("%d%d",&g,&m)) { getchar(); for(int i=0;i<g;i++) gets(girl[i]); for(int i=0;i<m;i++) { gets(wish[i]); for(int j=0;wish[i][j]!=0;j++) if(wish[i][j]<='Z'&&wish[i][j]>='A') wish[i][j]+=32; bool name=false; bool goodword=false; memset(gx,0,sizeof(gx)); char word[256]; int ii=0; int wordnum=0; for(int j=0;wish[i][j]!=0;j++) { if(wish[i][j]!=' '&&wish[i][j]!='!') word[ii++]=wish[i][j]; else if(wish[i][j+1]!=' '&&wish[i][j+1]!='!')//Get a word successfully { wordnum++; word[ii]=0; ii=0; for(int k=0;k<g;k++) { if(gx[k]==false&&strcmp(word,girl[k])==0) { gx[k]++; // if(name) // putchar(' '); // printf("%s",girl[k]); name=true; } }//Find name if(goodword==false&&(strcmp(word,beautiful)==0||strcmp(word,pretty)==0||strcmp(word,lovely)==0)) goodword=true; } } if(ii!=0) { wordnum++; word[ii]=0; ii=0; for(int k=0;k<g;k++) { if(gx[k]==false&&strcmp(word,girl[k])==0) { gx[k]++; // if(name) // putchar(' '); // printf("%s",girl[k]); name=true; } }//Find name if(goodword==false&&(strcmp(word,beautiful)==0||strcmp(word,pretty)==0||strcmp(word,lovely)==0)) goodword=true; } if(name==false) printf("All"); else { bool output=false; for(int j=0;j<g;j++) { if(gx[j]) { if(output) putchar(' '); printf("%s",girl[j]); output=true; } } } printf(": "); if(wordnum<=9) puts("oh"); else if(goodword==true) puts("xixi"); else puts("hehe"); } } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator