OLE和RE求助
查看原帖
OLE和RE求助
991345
circle__99楼主2025/7/23 10:58
#include <bits/stdc++.h>
using namespace std;
int Tree[256][256];
bool completivity[256];
int main(){
	memset(completivity,false,256);
	string pst;
	while(true){
		int depth=0;
		while(cin>>pst,pst!="()"){
			int m=pst.find(',');
			stringstream n,p;
			for(int i=1;i<m;i++) n<<pst[i];
			for(int i=m+1;i<sizeof(pst)-1;i++) p<<pst[i];
			int num;
			string ps=p.str();
			n>>num;
			int y=1;
			for(int i=0;i<sizeof(ps);i++){
				if(ps[i]=='L') y=y*2-1;
				else if(ps[i]=='R') y*=2;
			}
			Tree[sizeof(ps)-1][y-1]=num;
			completivity[sizeof(ps)]=true;
			if(sizeof(ps)>depth) depth=sizeof(ps);
		}
		bool cp=true;
		for(int i=0;i<depth;i++) if(completivity[i]==false){
			cp=false;
			break;
		}
		if(cp){
			for(int i=0;i<256;i++) for(int j=0;j<pow(2,i);j++) if(Tree[i][j]!=0) cout<<Tree[i][j]<<" ";
			cout<<endl;
		}else{
			cout<<"not complete"<<endl;
		}
	}
}
2025/7/23 10:58
加载中...