str1 = input() ipt = list(input()) new_list = [] if str1 == "C": a = ipt[0] ipt.append("0") count = 1 for i in ipt[1:]: if i == a: count += 1 else: if count != 1: new_list.append(str(count)) new_list.append(a) count = 1 else: new_list.append(a) a = i print("".join(new_list)) b = "" res_str = "" if str1=="D": for i in range(len(ipt)): if ipt[i].isdigit(): b = b+ipt[i] else: if b == "": res_str += ipt[i] else: res_str += int(b)*ipt[i] b = "" print(res_str)
1078 字符串压缩与解压 (20 分) python
猜你喜欢
转载自blog.csdn.net/weixin_41775301/article/details/87891892
今日推荐
周排行