Q576: Hiaku Review

// Accepted after a few WA !!

#include<iostream>
#include<cstdlib>
#include<string.h>
#include<stdio.h>

using namespace std;

int main(int argc, char *argv[])
{
    int count, num[3] = {5,7,5};
    bool k, t;
    char ar[250];
    while(gets(ar) != NULL)
    {
        if(strcmp(ar,"e/o/i") == 0)
            break;

        int a = 0, leng = strlen(ar);
        t = false;
        for(int i = 0; i <= 2; i++)
        {
            k = false;   count = 0;
            for(int j = a; ; j++)
            {
                if(ar[j] == '/' || j == leng)
                {
                    a = j + 1;
                    break;
                }
                if(ar[j] == 'a' || ar[j] == 'e' || ar[j] == 'i' || ar[j] == 'o' ||
                   ar[j] == 'u' || ar[j] == 'y' )
                {
                    if(k == false)
                    {
                        k = true;
                        count++;
                    }
                }
                else
                    k = false;
            }
            if(count != num[i])
            {
                cout << i + 1 << endl;
                t = true;
                break;
            }
        }
        if(t == false)
            cout << "Y\n";
    }
    system("PAUSE");
    return EXIT_SUCCESS;
}

Leave a Reply