hiho-1082(c++)
2015-02-04 16:21
148 查看
20150204
字符串替换
代码:
字符串替换
代码:
#include <iostream> #include <cctype> using namespace std; string source; bool equals(char a,char b){ if(tolower(a) == tolower(b)) return true; return false; } int main() { string mode = "marshtomp"; string str = "fjxmlhx"; while(getline(cin,source)){ int n = 0; for(int i = 0; i < source.length();i++){ if(equals(source[i],mode )){ n++; if(n == mode.length()){ cout << str; n = 0; } }else if(n == 0){ cout << source[i]; }else{ int temp = 0; if(i >= 1 && n >= 5){ temp = 3; }else if(n == 1){ temp = 1; } for(int j = n; j >= temp; j--) cout << source[i-j]; i -= temp; n = 0; } if(i == source.length()-1 && n != 0){ for(int j = n - 1; j >= 0; j--) cout << source[i-j]; } } cout << endl; } return 0; }
相关文章推荐
- hiho #1082 : 然而沼跃鱼早就看穿了一切
- hiho-1014(c++)
- hiho-1015(c++)
- [hiho第92周]Miller-Rabin素性测试的c++实现
- hiho一下 第174周 - Dice Possibility【概率dp的简单运用 java & c++】
- hiho 1082 : 然而沼跃鱼早就看穿了一切
- hiho1082 : 然而沼跃鱼早就看穿了一切
- PAT程序设计考题——甲级1082( Read Number in Chinese ) C++实现
- POJ 2240 && ZOJ 1082 Arbitrage 最短路,c++ stl pass g++ tle 难度:0
- C/C++ PAT乙 1082. 射击比赛 (20)
- [HIHO1082]然而沼跃鱼早就看穿了一切(字符串水题)
- BZOJ1082_栅栏_C++
- hiho 1082 : 然而沼跃鱼早就看穿了一切
- C++ FAQ Lite[12]--赋值算符(新)
- 开发工具大比拚之Visual C++ vs. Delphi(三)
- 开发工具大比拚之Visual C++ vs. Delphi(二)
- 开发工具大比拚之Visual C++ vs. Delphi(一)
- Byte杂志C++调查报告
- 对今年内将出版的几本C++书的简评
- VC不是梦想,C++需要自由的心