Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

求指导!!!!!

Posted by crazy852456 at 2012-07-11 11:29:45 on Problem 1677
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
int find(char *a,char *b)
{
    int i,j,count,flag,lena,lenb;
    lena=strlen(a);
    lenb=strlen(b);
    flag=0;
    for(i=0;i<lena;i++)
    {    
       count=0;
       for(j=0;j<lenb;j++)
       {
           if(b[j]==a[i+j])
              count++;                   
       }
       if(count==lenb&&((a[i-1]==' '||a[i-1]=='!')&&(a[i+j]==' '||a[i+j]=='!')))
           flag=1;
    }
    return flag;
}
int main()
{
    char name[6][30];
    char wish[210];
    int flag[6];
    int k;  
    char a[10]={"beautiful"};
    char b[7]={"pretty"};
    char c[7]={"lovely"};  
    int g,w,word,count;
    while(~scanf("%d%d",&g,&w))
    {
        for(int i=0;i<g;i++)
           cin>>name[i];
        getchar();      
        while(w--)
        {
           gets(wish);
           word=0;
           count=0;
           memset(flag,0,sizeof(flag));
           for(int i=0;i<g;i++)
           {
               flag[i]=find(wish,name[i]);        
           }
           for(int i=0;i<strlen(wish);i++)
               if((wish[i+1]==' '||wish[i+1]=='!')&&((wish[i]>='a'&&wish[i]<='z')||(wish[i]>='A'&&wish[i]<='Z')))
                   word++;
           for(int i=0;i<g;i++)
           {
               if(flag[i]==1)
               {
                  if(count>0)
                     printf(" %s",name[i]);
                  else
                     printf("%s",name[i]);
                  count++; 
               }
            }         
           if(count==0) 
                   printf("All"); 
           printf(": ");
           if(word<=9)
               printf("oh\n");
           else if(word>=10&&(find(wish,a)||find(wish,b)||(find(wish,c))))
               printf("xixi\n");
           else if(word>=10)
               printf("hehe\n");
        }
    }  
    system("pause");  
    return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator