//AAABBBBCC–>A3B4C2
//将字符串按照字符+连续重复数格式化输出
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
char s[100];
cin>>s;
int len=strlen(s);
int count[100]={0},j=0;
for (int i=1;i<=len;i++)
{
if(s[i]==s[i-1])
{
count[j]++;
}else
{
cout<<s[i-1]<<(count[j]+1);
j++;
}
}
return 0;
}
(1)AAABBBBCC–>A3B4C2
最新推荐文章于 2020-10-23 11:58:23 发布