游程编码

这篇博客主要介绍了游程编码的概念和应用,通过同学的参考资料进行了深入的解析,为读者提供了全面的理解。
摘要由CSDN通过智能技术生成

在这里插入图片描述

#include<stdio.h>


#include <string.h>
int main()
{
   
	char input[128];
	while(~scanf("%s",input))
	{
   
		char output[128];
		memset(output,'\0',sizeof(output));
		int p=0;
		char now=input[p];
		int count=0;
		while(input[p]!='\0')
		{
   
			while(input[p]==now)
			{
   
				p++;
				count++;
			}
			char tmp[2],tmp2[128];
			tmp[0]=now;
			tmp[1]='\0';
			sprintf(tmp2,"%d",count);
			strcat(tmp2,tmp);
			strcat(output,tmp2);
			now=input[p];
			count=0;
		}
		printf("%s\n",output);
	}
	return 0;
}

不会阿阿阿阿阿为什么


同学写的1 参考

#include<stdio.h>
int main()
{
   
	int i;
	char temp;
	char sum[26] = {
    0 };
	for (i = 0; i < 100; i++)
	{
   
		temp = getchar();
		if (temp != '\n')
		{
   
			if ((temp >= 'a' && temp <= 'z') || (temp >= 'A' && temp <= 'Z'))
			{
   
				switch (temp)
				{
   
				case 'a':case 'A':sum[0]++; break;
				case 'b':case 'B':sum[1]++; break;
				case 'c':case 'C':sum[2]++; break
  • 4
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值