Uva 12289 Solution

#include<bits/stdc++.h>
using namespace std;
int main()
{
    string ch;
    int l, a, b, n, i;
    while(cin >> n)
    {
        for(i=1; i<=n; i++)
        {
            a = b = 0;
            cin >> ch;
            l = ch.size();
            if(l == 5)
                cout << 3 << endl;
            else
            {
                if(ch[0] == 'o')
                    a++;
                else
                    b++;
                if(ch[1] == 'n')
                    a++;
                else
                    b++;
                if(ch[2] == 'e')
                    a++;
                else
                    b++;
                if(a > b)
                    cout << 1 << endl;
                else
                    cout << 2 << endl;
            }
        }
}
return 0;
}

Comments