字符串处理__2019.03.17

 

#include <iostream>
#include <string.h>
#include <string>
#include <list>
using namespace std;

void fun()
{
	char ch[100] = {0};
	string InPut;
	cin >> InPut;
	strcpy(ch,InPut.c_str());
	list<char> temp;
	int i = 0;
	while (ch[i] != '\0')
	{
		temp.push_back(ch[i]);
		int n = 1;
		while (ch[i] == ch[i + 1])
		{
			++n;
			++i;
		}
		char Cn = (char)('0' + n);
		temp.push_back(Cn);
		++i;
	}
	while (!temp.empty())
	{
		cout << temp.front();
		temp.pop_front();
	}
}

int main()
{
	fun();
	return 0;
}

猜你喜欢

转载自blog.csdn.net/weixin_40316053/article/details/88620973