当前位置:网站首页>Word processing software

Word processing software

2022-07-05 01:42:00 Stars are not last night 334

Title Description

You need to develop a word processing software . At the beginning, enter a string ( No more than 100 Characters ) As the initial document . It can be considered that the beginning of the document is 0 Characters . The following operations need to be supported :

  • 1 str: Followed by insertion , Insert a string after the document str, And output the string of the document .

  • 2 a b: Intercept the document part , Only keep documents from a Start with two characters b Characters , And output the string of the document .

  • 3 a str: Insert clip , In the document, section a Insert a string before characters str, And output the string of the document .

  • 4 str: Find substring , Find string str In the first place in the document and output ; If the output cannot be found -1.

To simplify the problem , Specify the initial document and the... In each operation str There are no spaces or line breaks . There will be at most q(q≤100)  operations .

Input format

nothing

Output format

nothing

I/o sample

Input #1 Copy

4
ILove
1 Luogu
2 5 5
3 3 guGugu
4 gu

Output #1 Copy

ILoveLuogu
Luogu
LuoguGugugu
3
#include<iostream>
#include<cmath>
#include<string>
#include<fstream>
using namespace std;
int n,a;
string qwq;
string c1;
string b1;
int b,c,d=-1,e;// Not all useful 
int main()
{
	cin>>n;
	cin>>qwq;
	for(int i=0;i<n;i++)
	{
		cin>>a;
		if(a==1)// operation 1
		{
			cin>>b1;
			qwq+=b1;
			cout<<qwq<<endl;
		}
		else if(a==2)// operation 2
		{
			cin>>b>>c;
			c1=qwq.substr(b,c);
			qwq=c1;
			cout<<qwq;
			cout<<endl;
		}
		else if(a==3)// operation 3
		{
			cin>>b>>b1;
			qwq.insert(b,b1);
			cout<<qwq<<endl;
		}
		else if(a==4)// operation 4
		{
			cin>>b1;
			if(qwq.find(b1)<qwq.size())// If it cannot be found, it will return a strange number ( It's longer than the string anyway )
			cout<<qwq.find(b1)<<endl;
			else
			cout<<-1<<endl;
		}
	}
    return 0;
}

原网站

版权声明
本文为[Stars are not last night 334]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202141018486957.html