Uva Problem 12289 One-Two-Three Solution

Problem Link
Uva Problem 12289 One-Two-Three Solution

#include<bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    string s;
    cin>>n;
    while(n--)
    {
        cin>>s;
        if(s.size()==5)
            cout<<"3"<<endl;
        else
        {
            if((s[0]=='o' && s[1]=='n') || 
              (s[0]=='o' && s[2]=='e') || 
              (s[1]=='n' && s[2]=='e'))
                    cout<<"1"<<endl;
            else
                cout<<"2"<<endl;
        }
    }
    return 0;
}

No comments

Theme images by enjoynz. Powered by Blogger.