华为机试:查找字符串
2015-10-12 10:14
344 查看
#include <iostream>
#include <math.h>
#include <map>
#include <vector>
#include <string.h>
#include <memory>
#include <string>
#include <stdio.h>
#include <algorithm>
using namespace std;
int main()
{
string s , p;
int location = 0;
int count = 0;
cin >> s >> p;
location = s.find(p,location);
while(location != string::npos)
{
count++;
location = s.find(p,location + p.size() - 1);
}
cout << count << endl;
return 0;
}
相关文章推荐
- 【jQuery】判断浏览器类型和版本
- 三招让你的 APP 假装“更快”
- iOS抽奖转盘动画之转场动画与动画组
- 黑马程序员——Java语言的发展史
- Android学习之 面试资料整理[2]
- c++五种内存分配、堆与栈区别
- Git Flow
- 工业相机参数之帧率相关知识详解:
- Java中的小问题
- mvc的 404 处理
- 数字媒体技术3---wangronggang
- JS部分代码分享
- 再谈Java双括弧技巧:不规范的语法?
- C# Winform窗体自动运行隐藏
- 手工配置LVS
- 一个简单的定时器删除任务
- ASP.NET中Cookie状态的说明与用法
- Android系统文件安全权限检测/system/build.prop修改
- web前端绘制0.5像素的几种方法
- nodeclub models