too short on line求助
查看原帖
too short on line求助
545507
pl_cosmonaut楼主2021/8/17 23:10
#include<bits/stdc++.h>
using namespace std;
char a[105],back[105];
int main(){
	int q,n;
	cin>>q;
	cin>>a;
	for(int i=1;i<=q;i++){
		cin>>n;
		if(n==1){
			int temp;
			char str1[105];
			cin>>str1;
			temp=strlen(a);
			for(int j=temp;j<=temp+strlen(str1);j++){
				a[j]=str1[j-temp];
			}
			cout<<a<<endl;
		}
		if(n==2){
			int y,z;
			cin>>y>>z;
			for(int j=0;j<=z-1;j++){
				a[j]=a[j+y];
			}
			for(int j=y;j<=y-1+z;j++){
				a[j]=0;
			}
			cout<<a<<endl;
		}
		if(n==3){
			int x;
			cin>>x;
			char str3[105];
			cin>>str3;
			int temp;
			temp=strlen(a);
			for(int j=x;j<=temp-1;j++){
				back[j-x]=a[j];
			}
			for(int j=x;j<=x+strlen(str3);j++){
				a[j]=str3[j-x];
			}
			temp=strlen(a);
			for(int j=temp;j<=temp+strlen(back);j++){
				a[j]=back[j-temp];
			}
			cout<<a<<endl;
		}
		if(n==4){
			char str4[105];
			cin>>str4;
			int flag=1,flag2;
			for(int j=0;j<=strlen(a)-strlen(str4)+1;j++){
				flag2=1;
				for(int v=0;v<=strlen(str4)-1;v++){
					if(a[j+v]!=str4[v]) flag2=0;
				}
				if(flag2==1){
					flag=0;
					cout<<j<<endl;
					break;
				}
			}
			if(flag==1) cout<<-1<<endl;		
			}
	}
	return 0;
}

2021/8/17 23:10
加载中...