参考代码:
def match_strings(s1, s2):
i, j = 0, 0
while i < len(s1) and j < len(s2):
if s1[i] == s2[j]:
print(s1[i], end='')
i += 1
j += 1
else:
print(s1[i], end='')
i = i - j + 1
j = 0
print()
if j == len(s2):
return i - j + 1
else:
return 0
def main():
for _ in range(3):
s1, s2 = input().split()
position = match_strings(s1, s2)
print(position)
if __name__ == "__main__":
main()
0.0分
0 人评分