sicily 1156

#include <iostream> using namespace std; struct Node { char data; int left; int right; }; int n; Node node[1001]; void preorder(int tmp) { cout << node[tmp].data; if(node[tmp].left != 0) preorder(node[tmp].left); if(node[tmp].right != 0) preorder(node[tmp].right); } int main() { int index; int head = 0; while(cin >> n) { head = 0; for(int i = 0; i < n; i++) { cin >> index; cin >> node[index].data >> node[index].left >> node[index].right; //找头结点 head = head ^ index ^ node[index].left ^ node[index].right; } preorder(head); cout << endl; } return 0; } 

你可能感兴趣的:(sicily 1156)