#include <cstdio>
struct Node {
int left, right;
Node() { this->left = this->right = 0; }
}tree[30];
void pre_order(int u) {
putchar(u + 'a' - 1);
if (tree[u].left) pre_order(tree[u].left);
if (tree[u].right) pre_order(tree[u].right);
}
int main() {
int n;
scanf("%d\n", &n);
int root = 0;
while (n--) {
// printf("%d\n", n);
char a, b, c;
scanf("%c%c%c\n", &a, &b, &c);
//printf("%c %c %c\n", a, b, c);
if (!root) root = a - 'a' + 1;
if (b != '*') tree[a-'a'+1].left = b-'a'+1;
if (c != '*') tree[a-'a'+1].right = c-'a'+1;
}
pre_order(root);
putchar('\n');
return 0;
}
为什么本地命令行输入还要Ctrl+Z
?
???