sicily 1753

#include "iostream"
#include "cctype"
#include "string"
#include "sstream"
using namespace std;

int main()
{
	string str;
	while (cin >> str && str != "XXX")
	{
		int size;
		size = str.size();
		for (int i = 0; i < size; i++)
		{
			if (isdigit(str[i]))
			{
				int count = 0;//计算数字的个数
				int tag = i;//状态位的保存
				int tag1 = i;//状态位的保存
				int Num = 0;//保存由字符串转换过来的数字,即是前一个字母出现的个数
				while (isdigit(str[tag1]))//计算字符串中连续有多少个数字的出现的个数
				{
					count++;
					tag1++;
					if (tag1 >= str.size())  break;
				}
				string temp = "";
				for (int j = 1; j <= count; j++, tag++)//下面的步骤是讲字符串中的数字转换为int
				{
					temp += str[tag];
				}
				stringstream s;
				s << temp;
				s >> Num;
				for (int j = 1; j < Num; j++)//输出字母
					cout << str[i-1];
				i = i + temp.size() - 1;//得到获取了字符串中数字之后的游标位置,继续下个字母的检验
			}
			else
				cout << str[i];
		}
		cout << endl;
	}
}

 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值