poj 1575 Easier Done Than Said?

poj 1575 Easier Done Than Said?,第1张

poj 1575 Easier Done Than Said?
#include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;char st[50];bool v(char a){    return a =='a' ||a =='e' ||a =='i' ||a =='o' ||a =='u';}bool accept(){    int n = strlen(st);    bool found = false;    for (int i = 0; i < n; i++)        if (v(st[i]))        { found = true; break;        }    if (!found)        return false;    int count = 1;    for (int i = 1; i < n; i++)    {        if (v(st[i]) == v(st[i - 1])) count++;        else count = 1;        if (count >= 3) return false;    }    for (int i = 1; i < n; i++)        if (st[i] == st[i - 1] && st[i] != 'e' && st[i] != 'o') return false;    return true;}int main(){    while (scanf("%s", st), strcmp(st, "end"))    {        if (accept()) printf("<%s> is acceptable.n", st);        else printf("<%s> is not acceptable.n", st);    }    return 0;}

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/4924875.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-11-12
下一篇2022-11-12

发表评论

登录后才能评论

评论列表(0条)

    保存