题解 | #查找#
查找
https://www.nowcoder.com/practice/a988eda518f242c29009f8620f654ede
#include <algorithm> #include <iostream> #include <string> using namespace std; int main() { string s; cin >> s; int n; cin >> n; while (n--) { string cmd; cin >> cmd; int type = cmd[0] - '0'; int pos = cmd[1] - '0'; int len = cmd[2] - '0'; if (type == 0) { reverse(s.begin()+pos, s.begin()+pos+len); } else { s.replace(s.begin()+pos,s.begin()+pos+len,cmd.substr(3)); } cout<<s<<endl; } }