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

求大神解救。。感激不尽。。WAing。。QAQ。。

Posted by 201392347 at 2014-01-18 12:46:05 on Problem 1575
#include<cstdio>
#include<string.h>
char word[100];
int word_hash[100];
char ends[]="end";
int isac(char * word,int len)
{
    void hash(char *word ,int len);
    hash(word,len);
    int i=0;
    for(;i<=len;i++)
    {
        if(word_hash[i])
            break;
    }
    if(i==len+1)
        return 0;
    int isv(char s);
    if(len>=2)
    for(i=0;i<len-2;i++)
    {
        if(isv(word[i])&&isv(word[i+1])&&isv(word[i+2])||!isv(word[i])&&!isv(word[i+1])&&!isv(word[i+2]))
            return 0;
    }
    if(len>=1)
    for(i=0;i<len-1;i++)
    {

        if(word[i]=='e'||word[i]=='o')
            continue;
        if(word[i]==word[i+1])
            return 0;
    }
    return 1;
}
void hash(char *word,int len)
{
    int i=0;
    int isv(char s);
    for(;i<len;i++)
    {
        word_hash[i]=isv(word[i]);
    }
}
int isv(char s)
{
    if(s=='a'||s=='e'||s=='o'||s=='i'||s=='u')
        return 1;
    else return 0;
}
int main()
{
    while(scanf("%s",word)!=EOF&&strcmp(word,ends)!=0)
    {
        int len=strlen(word);
        memset(word_hash,0,4);
        if(isac(word,len))
            printf("<%s> is acceptable.\n",word);
        else printf("<%s> is not acceptable.\n",word);
        //printf("%d%d",word_hash[0],word_hash[1]);
    }
    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