题解 | #查找#

查找

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;
    }
}

全部评论

相关推荐

投递阿里巴巴控股集团等公司8个岗位 >
点赞 评论 收藏
转发
点赞 收藏 评论
分享
牛客网
牛客企业服务