| ||||||||||
| 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:基础题,不难,可是做得我想吐血~ 各种细节In Reply To:基础题,不难,可是做得我想吐血~ 各种细节 Posted by:wjwjw at 2011-01-29 11:54:00 > MARK!
>
> #include<iostream>
> #include<string.h>
> using namespace std;
> int main()
> {
> char str[70][100];
> int len[70];
> char key[25][25];
> int k,e;
> int t=0;
> int i,j;
> char temp_key[25];
> char temp[100];
> int max_len;
> while(scanf("%d%d",&k,&e)!=EOF)
> {
> max_len=0;
> for(i=0;i<k;i++)
> scanf("%s",key[i]);
> getchar();
> for(i=0;i<e;i++)
> {
> gets(str[i]);
> strcpy(temp,str[i]);
> len[i]=0;
> for(j=0;temp[j]!='\0';j++)
> {
> if (isalpha(temp[j])) {
> temp[j] = tolower(temp[j]);
> } else {
> temp[j] = ' ';
> }
> }
> char *p=temp;
> while(sscanf(p,"%s",temp_key)>0)
> {
> p++;
> p+=strlen(temp_key);
> for(j=0;j<k;j++)
> if(strcmp(temp_key,key[j])==0)
> len[i]++;
> }
> if(len[i]>len[max_len])
> max_len=i;
> }
> printf("Excuse Set #%d\n",++t);
> for(i=0;i<k;i++)
> if(len[i]==len[max_len])
> printf("%s\n",str[i]);
> printf("\n");
> }
> return 0;
> }
这种做法很巧妙
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator