题目链接: 点这里
练习使用字符串的函数:
- length(), 与size(), 效果一样
- insert(pos, str): pos表示下标
- find(str)与rfind(str):str开头的下标
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main() {
string a, b;
int n;
cin >> a >> n >> b;
if (a.length() > 100) cout << 100 << endl;
else cout << a.length() << endl;
a.insert(n - 1, b);
cout << a << endl;
cout << a.size() - a.rfind("x") << endl;
return 0;
}