求调
查看原帖
求调
1085002
liuyelan楼主2025/1/13 20:34

废话不多说,上代码:

#include <bits/stdc++.h>
using namespace std;

char c,c1;
struct Node {
	char l,r;
}t[1000010];

void dfs(char x){//根左右 
    if(x=='*'){
    	return;
	}
	cout<<x;
	if(t[x].l) dfs(t[x].l);
	if(t[x].r) dfs(t[x].r);
}
int main(){
	int n;
	cin>>n;
	cin>>c;
	cin>>t[1].l;
	cin>>t[1].r;
	for(int i=2;i<=n;i++){
		cin>>c1;
		cin>>t[i].l;
		cin>>t[i].r;
	}
	dfs(c);
	return 0;
}

题目的样例数据,只输出a......

2025/1/13 20:34
加载中...