Codeforces #185 Div2 A "Whose sentence is it"
問題
http://codeforces.com/contest/312/problem/A
訳
ある日 liouzhou_101はFredaとRainbowのチャットの記録を入手した。好奇心から、彼は会話文がFredaが話したのか?Rainbowが話したのかが知りたくなった。彼の経験からいって、Fredaは語尾にいつも"lala."をつけ、Rainbowは語頭にいつも"miao."をつけていた。チャットの記録の各会話文について、どちらが話したのかを解析せよ。
制約
1 <= 会話文の数 <= 10
考えた事
やるだけ
30分かかったけどね!!
ソースコード
int main() { int n; cin >> n; cin.ignore(); for( int i = 0; i < n; i++ ){ string sentence; getline( cin, sentence ); int len = sentence.length(); bool Freda = false, Rainbow = false; if( len >= 5 ){ if( sentence.substr( len - 5 ) == "lala." ){ Freda = true; } if( sentence.find( "miao." ) == 0 ){ Rainbow = true; } } if( Freda && !Rainbow ){ cout << "Freda's" << endl; }else if( !Freda && Rainbow ){ cout << "Rainbow's" << endl; }else{ cout << "OMG>.< I don't know!" << endl; } } }