20pts求助(我竟然会跌到这种题上)
查看原帖
20pts求助(我竟然会跌到这种题上)
1053122
shy_lihui楼主2024/8/28 21:56
#include<bits/stdc++.h>
using namespace std;
int n;
string s;
int main()
{
	cin>>n;
	cin>>s;
	while(n--)
	{
		int op;
		cin>>op;
		if(op==1)
		{
			string str;
			cin>>str;
			s.append(str);
			cout<<s<<'\n';
		}
		if(op==2)
		{
			int l,r;
			cin>>l>>r;
			s.substr(l,l+r);
			cout<<s<<'\n';
		}
		if(op==3)
		{
			int x;
			string str;
			cin>>x>>str;
			s.insert(x,str);
			cout<<s<<'\n';
		}
		if(op==4)
		{
			string str;
			cin>>str;
			if(s.find(str)!=string::npos)
			{
				cout<<s.find(str)<<'\n';
			}
			else
			{
				cout<<"-1\n";
			}
		}
	}
	return 0;
}
2024/8/28 21:56
加载中...