字符串忽略大小写

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值