字符串忽略大小写

hihocoder1082https://hihocoder.com/problemset/problem/1082

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<cstring>
 4 #include<algorithm>
 5 #include<cstdlib>
 6 #include<string>
 7 #include<cmath>
 8 #include<vector>
 9 #include<stack>
10 #include<iterator>
11 #include<queue>
12 #include<cctype>
13 #define lson l, m, rt<<1
14 #define rson m+1, r, rt<<1|1
15 #define IO ios::sync_with_stdio(false);cin.tie(0);
16 #define INF 0x3f3f3f3f
17 #define MAXN 100010
18 const int MOD=1e9+7;
19 typedef long long ll;
20 using namespace std;
21 int t, n, m;
22 string s, ss, a = "marshtomp", b = "fjxmlhx"; 
23 int main()
24 {
25     IO;
26     while(getline(cin, ss)){
27         s = ss;
28         transform(s.begin(), s.end(), s.begin(), ::tolower);//全部转小写字母 
29         int t = s.find(a);//找(串)
30         while(t != -1){
31             ss.erase(t, 9);s.erase(t, 9);//擦除(位置,个数)
32             ss.insert(t, b);s.insert(t, b);//插入(位置,串)
33             t = s.find(a);
34         }
35         cout << ss << endl;
36     }
37     return 0;
38 }
原文地址:https://www.cnblogs.com/Surprisezang/p/8673444.html