#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;
}
}
sicily 1753
最新推荐文章于 2016-01-09 18:14:00 发布