#include <iostream>
#include <string.h>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
void RLC(char *s)//游程编码
{
int i=0;
while(*s)
{
if(*s=='1') i++;
else if(*s=='0')
{
printf("%d",i);
i=0;
}
s++;
}
if(i>0) printf("%d",i);//输出末尾可能存在的 1 个数
}
int main(int argc, char** argv) {
char s[]="11011100010101";
RLC(s);
return 0;
}
急求!!!上面的测试向量,如果里面的1的个数过多,例如00 110 111111111 1110 00 10 10 1,根据10进制的要求,需要进行切分为9个1和3个1,这里该怎么修改,才能得到结果为0029300111,谢谢了!
谢谢你的建议,我说的你可能不理解