3.2—字符串—Implement strStr()
来源:互联网 发布:网络女主播圈子很乱 编辑:程序博客网 时间:2024/06/05 22:50
描述
Implement strStr().
Returns a pointer to the first occurrence of needle in haystack, or null if needle is not part of haystack.
Implement strStr().
Returns a pointer to the first occurrence of needle in haystack, or null if needle is not part of haystack.
#include<iostream>#include<string>#include<vector>using namespace std;int ImplementStr(string mainstr, string substr){int mainlegth = mainstr.size();int sublength =substr.size();for (int i = 0; i < mainlegth;i++){int k = i;int j;for (j = 0; j < sublength;j++){if (mainstr[k] == substr[j]&&k<mainlegth){k++;}elsebreak;}if (j == sublength)return i;}return -1;}int main(){string mainstr = "I LOVE SEU UNIVERSITY IN NANJING china!";string substr = "china!";int index = ImplementStr(mainstr, substr);cout << index << endl;}
阅读全文
0 0
- 3.2—字符串—Implement strStr()
- LeetCode—Implement strStr()
- 【字符串匹配】Implement strStr()
- 字符串匹配Implement strStr()
- leetcode---implement-strstr---字符串
- LeetCode——Implement strStr()
- LeetCode28——Implement strStr()
- <28>—— Implement strStr()
- Algorithms—28.Implement strStr()
- 【KMP&字符串匹配】Implement strStr()
- [LeetCode]Implement strStr() 字符串匹配
- leetcode 字符串匹配Implement strStr()
- [LeetCode] Implement strStr()[字符串hash]
- [leetcoide] 【字符串】28. Implement strStr()
- (LeetCode)Implement strStr() --- 匹配字符串
- Implement strStr()--字符串匹配_kmp_bkdHash
- Implement strStr(字符串查找)
- Leetcode刷题记——28. Implement strStr(实现strStr)
- 【R语言】问题处理
- editText设置输入最大值(不是长度)
- zip map
- Cobbler多系统自动化安装
- win7下批处理bat文件:切换网络设置
- 3.2—字符串—Implement strStr()
- Redis---- php简单操作
- QuartZ Cron表达式
- Charles辅助调试接口
- hdu
- 初学linux,在Linux上创建c程序并运行!
- 单例模式还是静态类
- java基础复习-多线程UDP
- HDU6073 Matching In Multiplication【拓扑】