#include<stdio.h>
#include<string.h>
int main(void)
{
int n, i, x, y, j, z;
char a[101], temp[100],temp2[100];
scanf("%d", &n);
scanf("%s", a);
for (i = 0; i < n; i++)
{
scanf("%d", &z);
if (1 == z)
{
scanf("%s", temp);
strcat(a, temp);
puts(a);
}
else if (2 == z)
{
scanf("%d %d", &x, &y);
for (j = x; j < x+y; j++)
{
temp[j - x] = a[j];
}
for (j = 0; j < y; j++)
{
a[j] = temp[j];
}
a[y] = '\0';
puts(a);
}
else if (3 == z)
{
scanf("%d", &x);
scanf("%s", temp);
for (j = 0; a[j+x]!='\0'; j++)
{
temp2[j] = a[j + x];
}
a[x] = '\0';
temp2[j] = '\0';
strcat(temp, temp2);
strcat(a, temp);
puts(a);
}
else if (4 == z)
{
scanf("%s", temp);
if (strstr(a, temp) == NULL)
{
puts("-1");
}
else
printf("%d\n", strstr(a, temp) - a);
}
}
return(0);
}
洛谷P5734 【深基6.例6】文字处理软件经典解法
最新推荐文章于 2024-07-31 22:05:56 发布