字符串替换 hihoCoder1082 然而沼跃鱼早就看穿了一切
来源:互联网 发布:中国gdp增速放缓知乎 编辑:程序博客网 时间:2024/06/07 12:50
一直因为C++里面没有现成的替换函数而烦恼,只怪自己太懒懒的写
借这题写好这个函数,,以后直接用就好了
#include<map>#include<set>#include<cmath>#include<stack>#include<queue>#include<cstdio>#include<string>#include<vector>#include<cstring>#include<iostream>#include<algorithm>#include<functional>using namespace std;const int MX = 1e3 + 5;string Replace(string s, string a, string b, bool Match = false) { string tmp = s; if(!Match) { transform(tmp.begin(), tmp.end(), tmp.begin(), ::tolower); transform(a.begin(), a.end(), a.begin(), ::tolower); } int pos; while(true) { if((pos = tmp.find(a)) != -1) { tmp.replace(pos, a.length(), b); s.replace(pos, a.length(), b); } else break; } return s;}char S[MX], a[MX] = "marshtomp", b[MX] = "fjxmlhx";int main() { while(gets(S)) { printf("%s\n", Replace(string(S), string(a), string(b)).c_str()); } return 0;}
0 0
- 字符串替换 hihoCoder1082 然而沼跃鱼早就看穿了一切
- hihocoder1082 然而沼跃鱼早就看穿了一切
- 然而沼跃鱼早就看穿了一切 hihoCoder1082
- 【hihocoder1082】然而沼跃鱼早就看穿了一切——字符串
- #1082 : 然而沼跃鱼早就看穿了一切
- #1082 : 然而沼跃鱼早就看穿了一切
- #1082 : 然而沼跃鱼早就看穿了一切
- #1082 : 然而沼跃鱼早就看穿了一切
- 然而沼跃鱼早就看穿了一切
- hiho1082 : 然而沼跃鱼早就看穿了一切
- #1082 : 然而沼跃鱼早就看穿了一切
- #1082 : 然而沼跃鱼早就看穿了一切
- 然而沼跃鱼早就看穿了一切
- 然而沼跃鱼早就看穿了一切
- 然而沼跃鱼早已看穿了一切——字符串替换
- HihoCoder#1082 : 然而沼跃鱼早就看穿了一切
- hihoCoder:#1082 然而沼跃鱼早就看穿了一切
- 然而沼跃鱼早就看穿了一切(暴力+懒惰标记)
- 黑马程序员———Java编程基础之数组
- JackSon 数据之间的转换 java
- [拓展]杭电1003(最大子数组问题)
- cin与cout
- 1、为什么每个viewDidLoad方法中都要使用[super viewDidLoad] ?
- 字符串替换 hihoCoder1082 然而沼跃鱼早就看穿了一切
- 在Linux系统下安装mysql
- 学习hadoop(2)单词统计
- 【C++ STL学习之五】容器set和multiset
- ssh常用用法小结
- 黑马学习笔记_javaIO(二)
- SQL like模糊查询
- iGrimaceVX3.0.0基本使用教程
- jeecms之入口解决和模板复制