由於只會出現1,2,3這三種可能性,所以直接判斷最像三個之中哪一個即可。
C++(0.024)
/*******************************************************/
/* UVa 12289 - One-Two-Three */
/* Author: Maplewing [at] knightzone.studio */
/* Version: 2012/07/15 */
/*******************************************************/
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
int n;
string s;
int oneortwo;
while( scanf( "%d", &n ) != EOF ){
getchar();
for( int i = 0 ; i < n ; i++ ){
getline( cin, s );
if( s.length() == 5 ) printf( "3\n" );
else{
oneortwo = 0;
if( s[0] == 'o' ) oneortwo++;
if( s[1] == 'n' ) oneortwo++;
if( s[2] == 'e' ) oneortwo++;
if( oneortwo >= 2 ) printf( "1\n" );
else printf( "2\n" );
}
}
}
return 0;
}