zoj_1698

好吧,今天就到此为止吧。。虽然做的题都好水,但是算是完成任务啦。。睡觉喽~

/*
zoj_1698    字符串处理
简单题,按照三个要求依次检查即可。
*/
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;

bool vowel( char c )
{
    if( c=='a' || c=='e' || c=='i'
        || c=='o' || c=='u' )
        return true;
    return false;
}

bool check( string s )
{
    int i,count1,count2;
    for( i=0;i<s.size();i++ )
    {
        if( vowel( s[i] ) )
            break;
    }
    if( i==s.size() )   return false;
    for( i=1;i<s.size();i++ )
    {
        if( s[i]==s[i-1] &&  s[i]!='e' && s[i]!='o' )
            return false;
    }
    count1=0;
    count2=0;
    for( i=0;i<s.size();i++ )
    {
        if( vowel( s[i] ) )
        {
            count1++;
            count2=0;
            if( count1>=3 ) return false;
        }
        else
        {
            count2++;
            count1=0;
            if( count2>=3 ) return false;
        }
    }
    return true;
}

int main()
{
    string s;
    while( cin>>s && s!="end" )
    {
        if( check( s ) )
            cout<<"<"<<s<<"> is acceptable.\n";
        else    cout<<"<"<<s<<"> is not acceptable.\n";
    }
    return 0;
}


你可能感兴趣的:(zoj_1698)