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

外星密码 - 题解

#include<bits/stdc++.h>

using namespace std;

string expand(){
	string s="",X;
	char c;int D;
	while(cin>>c){
		if(c=='['){
			cin>>D;   //输入完数字后,则到 ] 都要输入,用X来存储 
			X = expand();
			while(D--) s +=X;//数字是几,则扩大几倍 
			
		}
		else if(c==']') return s; //结束条件 
		else s+=c;  //存储数字后的字符  返回后,则存于X里 
	}
	return s;
} 
int main(){
	cout<<expand()<<endl;
	return 0;
}
0 回复 0 转发 2 喜欢 0 阅读
回复 (0)
默认 最新
暂无回复,快来抢沙发!