华为(C++实现字符串压缩程序)
来源:互联网 发布:窗帘品牌 知乎 编辑:程序博客网 时间:2024/05/16 18:01
#include<iostream>#include<string>using namespace std;void string_zip(string input,string &output){if(input.empty())return ;char last='\0';char current;int count=0;for(int i=0;i<input.size();++i){current=input[i];if(current==last||last=='\0'){count++;last=current;}else{if(count>1){output.push_back(count+'0');}output.push_back(last);count=1;last=current;}}if(count>1)output.push_back(count+'0');output.push_back(last);}int main(){string input("aabbbbccd");string output;string_zip(input,output);cout<<output<<endl;system("pause");return 0;}
0 0
- 华为(C++实现字符串压缩程序)
- 华为字符串压缩程序
- 华为2014年机试题【字符串压缩】-【C语言/C++】
- 字符串压缩(华为)
- 第十六题 2014华为机试题 字符串压缩程序
- 华为机试题---字符串压缩
- 华为上机练习题--压缩字符串
- 华为机试题2014 字符串过滤程序 java实现
- 算法思维——字符串压缩程序(华为2014校园招聘的机试题目)
- 一个字符串压缩程序
- 字符串压缩程序
- 一个字符串压缩程序
- 2014华为机试题-字符串压缩
- 字符串压缩(华为2014,机试)
- 2013华为机试字符串压缩
- 华为机试 题目3 - 字符串压缩
- 华为笔试题之字符串压缩
- (华为机试)字符串压缩
- Hello Golang
- C/C++ Development Library
- js 的一些小技巧2
- Android开发教学视频---mars老师讲解!
- JAVA学习笔记(三十六)- 文件的拆分和合并
- 华为(C++实现字符串压缩程序)
- 15第三周项目五——数组作数据成员(2)
- Linux rpm 命令参数使用详解[介绍和应用]
- HTML防止input回车提交表单
- x265的CMake编译参数设置
- 关于android 使用bitmap的OOM心得和解决方案
- 转 命令行下玩VC
- A list of open source C++ libraries
- #define变量