
(1)如果输入s的值不变,输入p为“ab”,则同源词的起点为
(2)实现上述功能的部分Python程序如下,请在划线处填入合适的代码。
s=input('请输入s:')
p=input(请输入p:')
scount=[0]*26
pcount=[0]*26
m=len(s)
n=len(p)
ans=[]
def pos(c):
if
return ord(c)-65
else:
return ord(c)-97
for i in range(n):
scount[pos(s[i])]+=1
pcount[pos(p[i])]+=1
if scount==pcount:
ans.append(0)
for i in range(m-n):
scount[pos(s[i])]-=1
scount[
if scount==pcount:
ans.append
print('同源词起点为:', ans, end=" ")

同类型试题

y = sin x, x∈R, y∈[–1,1],周期为2π,函数图像以 x = (π/2) + kπ 为对称轴
y = arcsin x, x∈[–1,1], y∈[–π/2,π/2]
sin x = 0 ←→ arcsin x = 0
sin x = 1/2 ←→ arcsin x = π/6
sin x = √2/2 ←→ arcsin x = π/4
sin x = 1 ←→ arcsin x = π/2


y = sin x, x∈R, y∈[–1,1],周期为2π,函数图像以 x = (π/2) + kπ 为对称轴
y = arcsin x, x∈[–1,1], y∈[–π/2,π/2]
sin x = 0 ←→ arcsin x = 0
sin x = 1/2 ←→ arcsin x = π/6
sin x = √2/2 ←→ arcsin x = π/4
sin x = 1 ←→ arcsin x = π/2

