全WA,但测试数据都和结果一样啊,求大佬帮忙
查看原帖
全WA,但测试数据都和结果一样啊,求大佬帮忙
1525158
chiyuwang楼主2024/10/23 10:42
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int q;
	cin >> q;
	string a;
	string m;
	cin >> a;
	for (int i = 1; i <= q; i++) {
		int t;
		cin >> t;
		if (t == 1) {
			string s;
			cin >> ws;
			getline(cin, s);
			a += s;
			cout << a << endl;
		}
		if (t == 2) {
			int p, o;
			cin >> p >> o;
			m = a.substr(p, o);
			cout << m << endl;
		}
		if (t == 3) {
			int pos2;
			cin >> pos2;
			string  b;
			cin >> ws;
			getline(cin, b);
			m.insert(pos2, b);
			cout << m << endl;
		}
		if (t == 4) {
			string k;
			cin >> ws;
			getline(cin, k);
			cout << int(m.find(k)) << endl;
		}
	}
	return 0;
}
2024/10/23 10:42
加载中...