本文共 969 字,大约阅读时间需要 3 分钟。
???????????????????????o(???)o???????????????????????????????????????????(??????)?????????????????????????????????????????(?_?)?????????????????????????????????????????????~~o(>_<)o~~?
?????????????????????????????????????????????????????
def circle(s_str): stack = [] for i in range(len(s_str)): if s_str[i] == '(': stack.append(i) if not s_str or '(' not in s_str: return s_str else: lIndex = stack.pop() for i in range(lIndex + 1, len(s_str)): if s_str[i] == ')': rIndex = i break res = s_str[:lIndex] + s_str[rIndex - 1:lIndex:-1] + s_str[rIndex + 1: len(s_str)] return circle(res)s = input().split()s_str = ''.join(s)print(circle(s_str)) ????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
????????????????????????????????????(??????????)??????????????????????????????????????
转载地址:http://nqxn.baihongyu.com/