HDU 1039(水题)

来源:互联网 发布:户外驴友用哪个软件 编辑:程序博客网 时间:2024/06/06 13:08

题意:如题。

 

#include <cstdio>#include <cstring>#include <string>#include <algorithm>#include <iostream>using namespace std;bool vowel(char c){    return c == 'a' || c == 'e' || c == 'i'         || c == 'o' || c == 'u';}bool consonant(char c){    return !vowel(c);}bool except(char c){    return c != 'e' && c != 'o';}void deal(string& line){    bool vowel_exist = false;    bool ok = true;    for (int i = 0; i < line.length() && ok; ++i)    {        if (vowel(line[i]))        {            vowel_exist = true;            if (i < line.length()-2 && vowel(line[i+1]) && vowel(line[i+2]))                ok = false;        }        else        {            if (i < line.length()-2 && consonant(line[i+1]) && consonant(line[i+2]))                ok = false;        }        if (i < line.length()-1 && line[i] == line[i+1] && except(line[i]))             ok = false;    }    if (!vowel_exist) ok = false;    cout << "<" << line << ">" << " is " << (ok ? "" : "not ")         << "acceptable." << endl;}int main(){    //freopen("1.txt", "r", stdin);    string line;    while (getline(cin, line))    {        if (line == "end")            break;        deal(line);    }    return 0;}


 

0 0
原创粉丝点击