返回题解分享
讨论 / 题解分享/ 帖子详情

解码(编程题) - 题解

#include <bits/stdc++.h>
using namespace std;
#define int long long
// #define LL long long
#define endl '\n'

void solve()
{
	string s;
	cin >> s;

	for (int i = 0; i < s.length(); i++)
	{
		if (isdigit(s[i + 1]))
		{
			for (int j = 1; j <= s[i + 1] - '0'; j++)
			{
				cout << s[i];
			}
			i++; // 跳过数字
		}
		else
		{
			cout << s[i];
		}
	}
}

signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);

	solve();

	return 0;
}
0 回复 0 转发 0 喜欢 0 阅读
回复 (0)
默认 最新
暂无回复,快来抢沙发!