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 |
Re:wa无数次!!测试全过求大牛指教!!!!In Reply To:wa无数次!!测试全过求大牛指教!!!! Posted by:wocha at 2012-07-10 14:39:52 > #include<stdio.h> > #include<string.h> > int NumberWords(char s[]) > { > int i,j,n,m,k,l; > n=0; > l=strlen(s); > for(i=0;i<l;i++) > { > if((s[i]>='A'&&s[i]<='Z'||s[i]>='a'&&s[i]<='z')&&(s[i+1]==' '||s[i+1]=='!')) > { > n++; > } > } > return n; > } > int girl[333]; > char str1[222][333]; > int FindWord(char s[]) > { > int len=strlen(s); > char d[343]; > int i,j; > for(i=0,j=0;i<len;i++) > { > if(s[i]==' ') > { > if(strncmp(s+j,"beautiful",strlen("beautiful"))==0) > { > > return 1; > } > if(strncmp(s+j,"pretty",strlen("pretty"))==0) > { > > return 1; > } > if(strncmp(s+j,"lovely",strlen("lovely"))==0) > { > > return 1; > } > if(strncmp(s+j,"Beautiful",strlen("Beautiful"))==0) > { > > return 1; > } > if(strncmp(s+j,"Pretty",strlen("Pretty"))==0) > { > > return 1; > } > if(strncmp(s+j,"Lovely",strlen("Lovely"))==0) > { > > return 1; > } > j=i+1; > } > } > return 0; > } > void FindGirls(char s[],int n) > { > int i,j,m,k,l; > l=strlen(s); > for(i=0,j=0;i<l;i++) > { > if(s[i]==' ') > { > for(k=0;k<n;k++) > { > char temp[333]; > strcpy(temp,str1[k]); > temp[0]-=32; > if(strncmp(s+j,str1[k],strlen(str1[k]))==0||strncmp(s+j,temp,strlen(temp))==0) > { > girl[k]=1; > break; > } > } > j=i+1; > } > } > } > int main() > { > int i,j,n,m,k,l,o,p; > char str2[222]; > while(~scanf("%d%d",&n,&m)) > { > for(i=0;i<n;i++) > { > scanf("%s",str1[i]); > } > getchar(); > while(m--) > { > gets(str2); > int len=strlen(str2); > for(i=0;i<len;i++) > if(str2[i]=='!') > str2[i]=' '; > for(i=0;i<=n;i++) > girl[i]=0; > FindGirls(str2,n); > int count=0; > for(i=0;i<n;i++) > { > if(girl[i]!=0) > count++; > } > > if(count==0) > { > printf("All:"); > if(NumberWords(str2)<=9) > { > printf(" oh\n"); > } > else > { > if(FindWord(str2)) > { > printf(" xixi\n"); > } > else > { > printf(" hehe\n"); > } > } > } > else > { > for(i=0;i<n;i++) > { > > if(girl[i]!=0) > { > if(count==1) > { > printf("%s:",str1[i]); > break; > } > else > { > printf("%s ",str1[i]); > count--; > } > } > > } > if(NumberWords(str2)<=9) > { > printf(" oh\n"); > } > else > > > { > if(FindWord(str2)) > { > printf(" xixi\n"); > } > else > { > 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