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;
}
#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;
}
相关文章推荐
- cisco低端交换机IOS升级失败的处理方法
- TI的Zigbee芯片 CC2530中添加波特率2400,4800等UART 波特率
- hadoop 云盘
- Win2003域控升级到WIN2008 R2 再升级到Windows server 2012
- ubuntu 用fcitx框架安装中文搜狗输入法
- HTML5表单验证
- VS2008中Run-Time Check Failure #2 - Stack around the variable 'xxx' was corrupted 错误解决方法
- 新东方短语表
- android笔记3——handler消息机制
- 2013-C++第13周项目参考解答链接集
- 万能作文
- Dom4j解析XML学习之利用解析的数据进行JDBC操作
- 南阳理工OJ_ASCII码排序
- Linux鸟哥私房菜学习笔记_第十章vim程序编辑器
- hbase+eclipse 常见问题解决方案
- 新东方四级核心词汇表
- asp.net调用sql server存储过程的实例
- Irrlicht学习之载入irr文件和自定义场景节点
- 缓存基础
- 五个字句顺序