Saturday, August 30, 2014

uva : 576 - Haiku Review


#include<stdio.h>
#include<string.h>
int main()
{
   // freopen("input.txt","r",stdin);
    char ch[1000];
    while(gets(ch)!=NULL)
    {
        if(strcmp(ch,"e/o/i")==0)break;
        int i=0,j,k,l,m=0,n=1,f=0,l1=0,l2=0,l3=0;
        while(ch[i]!='/')
        {
            if(ch[i]=='a'||ch[i]=='e'||ch[i]=='i'||ch[i]=='o'||ch[i]=='u'||ch[i]=='y')
            {
                m=1;
            }
            else
            {
                if(m==1)
                l1++;
                m=0;
            }
            i++;
        }
        if(m==1)
        {
            l1++;
            m=0;
        }
        i++;
        while(ch[i]!='/')
        {
            if(ch[i]=='a'||ch[i]=='e'||ch[i]=='i'||ch[i]=='o'||ch[i]=='u'||ch[i]=='y')
            {
                m=1;
            }
            else
            {
                if(m==1)
                l2++;
                m=0;
            }
            i++;
        }
        if(m==1)
        {
            l2++;
            m=0;
        }
        i++;
        ch[strlen(ch)]='/';
        while(ch[i]!='/')
        {
            if(ch[i]=='a'||ch[i]=='e'||ch[i]=='i'||ch[i]=='o'||ch[i]=='u'||ch[i]=='y')
            {
                m=1;
            }
            else
            {
                if(m==1)
                l3++;
                m=0;
            }
            i++;
        }
        if(m==1)
        {
            l3++;
            m=0;
        }
        i++;
        if(l1!=5)printf("1\n");
        else if(l2!=7)printf("2\n");
        else if(l3!=5)printf("3\n");
        else printf("Y\n");
    }
    return 0;
}

No comments:

Post a Comment