wzxcc @ 2024-11-08 18:52:22
p=int(input())
l=input()
z=[]
for j in range(p):
z.append(input().split())
for k in z:
if k[0]=="1":
l+=k[1]
print(l)
elif k[0]=="2":
l=l[int(k[1]):int(k[1])+int(k[2])]
print(l)
elif k[0]=="3":
l=l[:int(k[1])]+k[2]+l[int(k[1]):]
print(l)
else:
if k[1] in l:
for w in range(len(l)-len(k[1])+1):
if k[1]==l[w:w+len(k[1])]:
print(w)
break
else:
print(-1)
by 5k_sync_closer @ 2024-11-08 19:24:53
@wzxcc 行末有 \r
,用 rstrip 去掉就行了
p=int(input())
l=input().rstrip('\r')
for i in range(p):
s = input().rstrip('\r')
k = s.split()
if k[0]=="1":
l+=k[1]
print(l)
elif k[0]=="2":
l=l[int(k[1]):int(k[1])+int(k[2])]
print(l)
elif k[0]=="3":
l=l[:int(k[1])]+k[2]+l[int(k[1]):]
print(l)
else:
if k[1] in l:
for w in range(len(l)-len(k[1])+1):
if k[1]==l[w:w+len(k[1])]:
print(w)
break
else:
print(-1)
by 5k_sync_closer @ 2024-11-08 19:25:17
好像用的是 c++ 代码块,不管了
by wzxcc @ 2024-11-08 19:38:17
@5k_sync_closer 大哥为什么会多空格
by wzxcc @ 2024-11-08 19:43:29
@5k_sync_closer 谢谢大哥我懂了,题目好阴险,能问一下这种空格题目常见吗,我小白
by Stone165 @ 2024-11-26 08:47:56
@5k_sync_closer我也是同样的问题,感谢大佬