3546. 复制、剪切、粘贴

模拟。

string s,t;
int m;

int main()
{
    cin>>s>>m;

    while(m--)
    {
        string op;
        cin>>op;
        if(op == "COPY")
        {
            int l,r;
            cin>>l>>r;
            t=s.substr(l,r-l+1);
        }
        else if(op == "CUT")
        {
            int l,r;
            cin>>l>>r;
            t=s.substr(l,r-l+1);
            s.erase(l,r-l+1);
        }
        else
        {
            int pos;
            cin>>pos;
            s.insert(pos+1,t);
        }
        cout<<s<<endl;
    }
    //system("pause");
    return 0;
}
posted @ 2021-05-23 19:37  Dazzling!  阅读(48)  评论(0编辑  收藏  举报