1260:找子串
来源:互联网 发布:mysql条件查询语句 编辑:程序博客网 时间:2024/06/08 18:46
1260:找子串
Description
给定原子串和目标子串,要求你求得目标子串在原子串当中出现的次数。
Input
多组测试数据,每组测试数据第一行是原子串,第二行是目标子串。
子串长度不会超过100。
Output
输出目标子串在原子串当中出现的次数。
Sample Input
abc123abc
abc
aabcCdeAbcdeccde
cde
Sample Output
2
2
Source
ipc4th@ahstu
#include<iostream>#include<string>using namespace std;int main(){ string a,b; while(cin>>a>>b) { int length1=a.length(); int length2=b.length(); int i=0,j,count=0; while(i<length1) { for(j=i;j<i+length2;j++) { if(a[j]!=b[j-i]) break; } if(j==i+length2) count++; i++; } cout<<count<<endl; } return 0;}
阅读全文
0 0
- 1260: 找子串
- 1260:找子串
- 1260
- 1260
- poj1936找子串
- 1084 -- 找子串
- KMP--找子串
- 找子串个数的练习
- 实现找子串的编程
- poj3461 找子串出现的个数
- 1260 Pearls
- poj 1260
- URAL 1260
- POJ 1260
- POJ 1260
- ZOJ-1260
- poj-1260
- poj-1260
- Scala基础数据格式化输出总结
- SQL Server XML数据解析
- ADX345获取加速度在LCD显示
- 【极光推送】jpush服务端开发详尽过程
- HQL语法知识(二)
- 1260:找子串
- Java基础之--IO
- 增效工具
- python 退出 os._exit(), sys.exit(), exit()
- NAMP安装(一) Nginx的安装(1.8.1)
- 【Kafka】Broker之Server.properties的重要参数说明
- centos6.5升级python2.6到2.7 + 安装pip
- js向事件绑定的匿名函数内传递循环控制变量的值
- ajax post方式表单提交setRequestHeader报错解决方法