文章

7

粉丝

0

获赞

21

访问

1.1k

头像
查找 - 北邮 题解:依旧<string.h>
P1387 北京邮电大学
发布于2026年2月1日 22:35
阅读数 190

#include <bits/stdc++.h>
using namespace std;

int main() {
    string s;
    int n;
    while(cin >> s){
        cin >> n;
        vector<string> order(n); 
        for(int i = 0; i < n; i++)
        {
            cin >> order[i];
            int op = order[i][0] - '0';
            int pos = order[i][1] - '0';
            int len = order[i][2] - '0';
            if(op == 0){
                string sub = s.substr(pos, len);
                reverse(sub.begin(), sub.end());    // 原地操作
                s.replace(pos, len, sub);           // 原地操作
                cout << s <<endl;
            }
            if(op == 1){
                s.replace(pos, len, order[i].substr(3));
                cout << s << endl;
            }
        }
    }
    return 0;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发