⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 新建 文本文档 (2).txt

📁 使用C语言实现图像的游程编码压缩
💻 TXT
字号:
就是用C语言编辑一个程序,程序的功能就是压缩,比如说我写了11111(5个1)输出结果是1(5)的格式!就是这样!望高手把C的原代码帖出来!不胜感激!!
提问者: DGQ1627 - 试用期 一级 
最佳答案
/* http://zhidao.baidu.com/question/14290060.html */ 
/* 程序在gcc4.03 ubuntu dapper下编译运行通过 */ 
/* ahlongxp[at]gmail[dot].com */ 

#include <stdio.h> 
void rlc(char* str) 
{ 
int outlen = -1; 
int i = 0; 
char out[256] = ""; 
out[++outlen] = str[0]; 
out[++outlen] = '('; 
int curcount = 1; 
while(str[++i] !=0) 
{ 
if(str[i] == str[i-1]) 
{ 
++curcount; 
} 
else 
{ 
out[++outlen] = 48 + curcount; 
out[++outlen] = ')'; 
out[++outlen] = str[i]; 
out[++outlen] = '('; 
curcount = 1; 
} 
} 
out[++outlen] = 48 + curcount; 
out[++outlen] = ')'; 
out[++outlen] = 0; 
puts(out); 
} 

int main(int argc, char** argv) 
{ 
char test[] = "0111222233333450000007778"; 
rlc(test); 
return 0; 
} 

http://herofit.blogspot.com
回答者:ahlongxp - 举人 四级 10-23 20:57
提问者对于答案的评价:感觉不错,我在TC里运行出现2错误,不知道什么原因?还请查下~!谢

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -