您的位置:首页 > 其它

Bachelor's song

2013-11-22 20:12 288 查看
题目不难,但使用string中的find判断是否存在,且返回首字母的位置;由于为字符串,所以只要首字母小于总长度减去查询字符长度即可;

#include<iostream>
#include<cstdio>
#include<stdlib.h>
#include<cstring>

using namespace std;

const int maxn = 10005;
int main(){
string str;
string::size_type position;
int Case;
while( scanf( "%d", &Case ) != EOF ){
while( Case-- ){
cin >> str;
position = str.find( "LOVE" );
// cout << position << endl << str.length() << endl;
if( position < str.length() - 3 ){
puts( "LOVE");
}
else{
puts( "SINGLE" );
}
}
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  2400