Uva 12289 - One-Two-Three


 #include<cstdio>
#include<cstring>
#define sf scanf
#define pf printf

int main()
{
    int t;
    char ch[1001];
    sf("%d\n",&t);

    while(t--)
    {
        gets(ch);
        int len=strlen(ch);

        if(len==5)
        {
            pf("3\n");
        }

        else if(len==3)
        {
            if((ch[0]=='o' and ch[1]=='n') or (ch[0]=='o' and ch[1]=='e') 
or (ch[0]=='n' and ch[1]=='o') or (ch[0]=='n' and ch[1]=='e') 
or (ch[0]=='o' and ch[2]=='e') or (ch[0]=='o' and ch[2]=='n') 
or (ch[0]=='n' and ch[2]=='o') or (ch[0]=='n' and ch[2]=='e') or (ch[0]=='e' and ch[1]=='o') 
or (ch[0]=='e' and ch[1]=='n') or (ch[0]=='e' and ch[2]=='o')
 or (ch[0]=='e' and ch[2]=='n'))
            {
                pf("1\n");
            }

            else
            {
                pf("2\n");
            }
        }
    }

    return 0;
}

Comments

Popular posts from this blog

SPOJ-CMG - Collecting Mango

LightOJ 1009 - Back to Underworld

LeetCode Palindrome Number