用于存放学校的作业便于复习。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

30 lines
793 B

# 13:23
# 13:47
# pprint是第三方库,这里暂时不使用
raw = input() # 下标从0开始
_ = [print(part, f"\t位置为[{i}, {j + 1}]") for j in range(1, len(raw)) for i in range(0, j) if (part := raw[i:j + 1]) == part[::-1]]
# 输入:
# cccdeedccc
# 输出:
# cc 位置为[0, 2]
# ccc 位置为[0, 3]
# cc 位置为[1, 3]
# ee 位置为[4, 6]
# deed 位置为[3, 7]
# cdeedc 位置为[2, 8]
# ccdeedcc 位置为[1, 9]
# cc 位置为[7, 9]
# cccdeedccc 位置为[0, 10]
# ccc 位置为[7, 10]
# cc 位置为[8, 10]
# 输入:
# 上海自来水来自海上
# 输出:
# 来水来 位置为[3, 6]
# 自来水来自 位置为[2, 7]
# 海自来水来自海 位置为[1, 8]
# 上海自来水来自海上 位置为[0, 9]