1078. 字符串压缩与解压 (20)
来源:互联网 发布:js控制光标位置最右 编辑:程序博客网 时间:2024/05/17 02:44
#include <iostream>#include <string>using namespace std;string a;void deal1(){getline(cin, a);for(int i = 0; i < a.length(); i++){int count = 0;while(a[i] == a[i+1])i++, count++;if(count != 0)cout << count+1;cout << a[i];}}void deal2(){getline(cin, a);for(int i = 0; i < a.length(); i++){int sum = 0;while(a[i] <= '9' && a[i] >= '0')sum = sum*10 + a[i++]-'0';//数个数(两位以上的数字) for(int j = 0; j < sum; j++)cout << a[i];if(sum == 0)cout << a[i];}}int main(){char ch;cin >> ch;getchar();//吞回车 if(ch == 'C')deal1();else if(ch == 'D')deal2();cout << endl;return 0;}
阅读全文
0 0
- 1078. 字符串压缩与解压 (20)
- 1078. 字符串压缩与解压 (20)
- 1078. 字符串压缩与解压 (20)
- 1078. 字符串压缩与解压 (20) PAT乙级真题
- PAT 乙级 1078. 字符串压缩与解压 (20)
- 字符串的压缩与解压
- 压缩与解压1---字符串的压缩与解压
- 1078. 字符串压缩与解压(未拿满分)
- PAT (Basic Level) Practise (中文) 1078. 字符串压缩与解压 (20)
- (python3)1078. 字符串压缩与解压 (20分)——2017-12考题
- Java对字符串的压缩与解压
- IOS 压缩与解压字符串(文件) 操作
- 字符串压缩和解压
- GZipStream压缩解压字符串
- C#字符串压缩&解压
- C# 压缩与解压字符串(面试题)
- JAVA 实现文件(字符串)压缩与解压
- 文件压缩与解压
- 10.SparkStream例子HdfsWordCount
- PHP中分页功能的实现
- 解决oracle表被锁的问题
- 安装VNC-Server出现xauth: (argv):1: bad display name "[ip address]:1" in "add" command错误
- 【自定义函数封装】php-数组
- 1078. 字符串压缩与解压 (20)
- appium 报错总结一
- HTTP 状态代码列表
- BRDF双反射分布函数
- 洛谷P2536 [AHOI2005]病毒检测
- C++——指针学习
- 使用VMware安装linux虚拟机以及相关配置
- Deep learning:数据预处理技巧
- 基于注解的SpringMVC