图a



编写python程序,实现如下功能:输入两个字符环,输出其最长公共子串和长度。程序运行界面如图c所示。Python程序如下,请在划线处填人合适的代码。
s1=input("请输入第一个字符环:")
s2=input("请输入第二个字符环:")
len1=len(s1)
len2=len(s2)
minlen=len1
if len2<len1:
common=""
cl=0
for i in range(len1):
for j in range(len2):
temp=0;itemp=i;jtemp=j
while s1[itemp]==s2[jtemp] and temp < minlen:
temp+=1
itemp=
jtemp=
if temp>cl:
cl=temp
if i<=itemp:
common=s1[i:itemp]
else:
common=
print("两字符环的最长公共子串为:"+common+";长度为:",cl)

同类型试题

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

