分割字符串1
来源:互联网 发布:淘宝图片侵权处罚 编辑:程序博客网 时间:2024/05/17 22:37
用字符串d分割s
例如 d="."
s="www.baidu.com"
ret={"www","baidu","com"}
#include<iostream>#include<vector>#include<algorithm>#include<string>using namespace std;vector<string> split(const string &s,const string &d){ vector<string> result; int ms=d.length(); int begin,end; begin=end=0; while((end=s.find(d,end))!=string::npos){if(end!=begin) //避免插入空字符串 result.push_back(s.substr(begin,end-begin)); begin=end+ms; end=begin;}if(begin!=s.length()) //不加这这两行www.baidu.com被切成{"www","baidu"} result.push_back(s.substr(begin,end-begin));return result;}
0 0
- 字符串分割1&&字符串分割2
- 分割字符串1
- 面试常见问题1: 字符串分割
- 分割字符串
- 分割字符串
- 分割字符串
- 分割字符串
- 分割字符串
- 字符串分割
- 字符串分割
- 分割字符串
- 字符串分割
- 字符串分割
- 分割字符串
- 分割字符串
- 分割字符串
- 字符串分割
- 分割字符串
- thinkphp 常看tp拼接的sql语句
- hdu4276The Ghost Blows Light 树形dp+分组背包
- iOS的触摸与手势识别
- UI_Block
- django 分拆url文件
- 分割字符串1
- lua的开始之旅
- uva 1449 AC自动机
- leetcode 19:Remove Nth Node From End of List(15-10-7)
- MyEclipse报错Bad version number in .class file
- hdu 1800 Flying to the Mars trie
- MIME格式详细介绍
- 证券投资之股票投资
- thinkphp getField