求助,只能通过第五个测试数据
查看原帖
求助,只能通过第五个测试数据
506333
Dd1446012370楼主2021/4/5 19:27
#include <iostream>
#include<string>
#include<cstdio>
using namespace std;
int main()
{
	int num;
	string s;
	cin >> num >> s;
	for (int i = 0; i < num;i++)
	{
		int num2; string str;
		scanf("%d",&num2);
		if (num2 == 1)
		{
			cin >> str;
			s = s+str;
			cout << s << endl;
		}
		if (num2 == 2)
		{
			int first, second;
			scanf("%d %d", &first, &second);
			s = s.substr(first, second);
			cout << s << endl;
		}
		if (num2 == 3)
		{
			int third; string str;
			cin >> third >> str;
			s = s.insert(third, str);
			cout << s << endl;
		}
		if (num2 == 4)
		{
			string str;
			cin >> str;
			printf("%d", s.find(str)==string::npos ? -1:s.find(str));
		}
	}
	return 0;
}
2021/4/5 19:27
加载中...