解题思路:
注意事项:
参考代码:
n, times, cnt, res = input(), int(input()), 1, '' for i in range(times): res = '' if len(n) == 1: res += '1' + str(n) else: for j in range(len(n) - 1): if n[j] == n[j + 1]: cnt += 1 else: res += str(cnt) + n[j] cnt = 1 # if the last one is different from the previous one res += str(1) + n[-1] if n[-1] != n[-2] else '' # if the last one is the same as the previous one res += str(cnt) + n[0] if cnt != 1 else '' n = res print(res)
0.0分
3 人评分
【回文数(二)】 (C++代码)浏览:862 |
最长单词 (C语言代码)浏览:1355 |
Pascal三角 (C语言代码)浏览:1180 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:373 |
C语言程序设计教程(第三版)课后习题1.6 (C语言代码)浏览:694 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:676 |
C语言训练-求1+2!+3!+...+N!的和 (C语言代码)浏览:777 |
C语言程序设计教程(第三版)课后习题8.9 (C语言代码)浏览:817 |
【计算两点间的距离】 (C语言代码)浏览:1473 |
1054题解浏览:460 |