p型编码

点击查看代码
#include<iostream>
#include<cstring>
using namespace std;
char s[1005];
int main ()
{
	gets(s);
	int len=strlen(s);
	s[len+1]=0x3f3f3f3f;
	int cnt=1;
	for(int i=0;i<len;i++)
	{
		if(s[i+1]==s[i])
		{
			cnt++;
		}
		else
		{
			cout<<cnt<<s[i];
			cnt=1;
		}
	}
	return 0;
}
posted @ 2025-09-08 22:33  一只牛油果  阅读(6)  评论(0)    收藏  举报