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 |
为什么总是WA,求大牛!#include<stdio.h> #include<string.h> int main() { char name[5][100],sentence[200],word[200][100],print[5][100]; int g,w,i,j,k,n,m,p; while(~scanf("%d %d",&g,&w)) { for(i=0;i<g;i++) { scanf("%s",name[i]); } for(i=0;i<w;i++) { k=0,m=0; getchar(); gets(sentence); for(j=0;j<strlen(sentence);j++) { if((sentence[j]>='A' && sentence[j]<='Z') && (sentence[j+1]==' ' || sentence[j+1]=='!')) { word[k][m]=sentence[j]-'A'+'a'; k++,m=0; continue; } else if((sentence[j]>='a' && sentence[j]<='z') && (sentence[j+1]==' ' || sentence[j+1]=='!')) { word[k][m]=sentence[j]; k++,m=0; continue; } else if(sentence[j]>='A' && sentence[j]<='Z') word[k][m]=sentence[j]-'A'+'a'; else word[k][m]=sentence[j]; m++; } m=0,p=0; for(j=0;j<k;j++) { for(n=0;n<g;n++) { if(strcmp(word[j],"all")==0 || strcmp(word[j],"All")==0) { printf("All"); break; } else if(strcmp(word[j],name[n])==0) { strcpy(print[m],word[j]); m++; } else { p++; } } } if(p==g*k) printf("All"); p=0; if(m!=0) { for(n=0;n<g;n++) { for(j=0;j<m;j++) { if(strcmp(print[j],name[n])==0) if(p==0) { printf("%s",print[j]); p++; } else printf(" %s",print[j]); } } } printf(": "); if(k<=9) { printf("oh\n"); } else { for(n=0;n<k;n++) { if(strcmp(word[n],"beautiful")==0 || strcmp(word[n],"pretty")==0 || strcmp(word[n],"lovely")==0) { printf("xixi\n"); break; } } if(n==k) printf("hehe\n"); } } } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator