题解 | #查找#

查找

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")

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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