华为4.14机考第一题翻转字符串
while True: try: s = input() n = s.count('(') s = list(s) for j in range(n): c = 0 li = [] for k in s: if k =='(': c = c + 1 if k == ')': c = c - 1 li.append(c) for i in range(len(s)): if s[i] =='(': l = i + 1 c = c + 1 if s[i] == ')': r = i c = c - 1 if c == sorted(li)[-1]: s[l:r] = s[l:r][::-1] s.pop(l-1) s.pop(r-1) print(''.join(s)) except: break