题解 | #查找#

查找

https://www.nowcoder.com/practice/a988eda518f242c29009f8620f654ede

#include <iostream>
using namespace std;

int main() {
    string s;
    cin>>s;
    int n;
    cin>>n;
    string temp;
    for(int j=0;j<n;j++)
    {
        cin>>temp;
        int t=temp[1]-'0';
        int len=temp[2]-'0';
        if(temp[0]-'0'==0)
        {

            for(int i=0;i<len/2;i++)
            {
                char c=s[t+i];
                s[t+i]=s[t+len-1-i];
                s[t+len-1-i]=c;
            }
            cout<<s<<endl;
        }
        else {
            s=s.substr(0,t)+temp.substr(3)+s.substr(t+len);
            cout<<s<<endl;
        }

    }
    return 0;
        

}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

2025-12-17 13:34
复旦大学 算法工程师
回家当保安:复旦✌🏻,佬你的简历感觉挺好的,寒假日常hc比较少。佬可以过完年之后再试试,日常实习hc比较充足
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务