60分求助
查看原帖
60分求助
699471
yuxiaoyu20090104楼主2022/9/14 00:34
#include<iostream>
using namespace std;
string s;
string expand()
{
	string s = "", x = "";
	char c;
	int d;
	while (cin >> c)
	{
		if (c == '[')
		{
			cin >> d;
			x += expand();
			while (d--)
			{
				s += x;
			}
		}
		else if (c == ']')
		{
			return s;
		}
		else
		{
			s += c;
		}
	}
	return s;
}
int main()
{
	cout << expand();
	return 0;
}
2022/9/14 00:34
加载中...