/* Name: NYOJ--202--红黑树 Date: 14/04/17 18:31 Description: 用结构体模拟二叉树的节点,因为左旋右旋不影响中序遍历,所以直接中序遍历 */ #include<iostream> #include<cstring> using namespace std; struct node{ int left,right; }Tree[15]; void inOrderTraversal(int); int main() { // freopen("in.txt","r",stdin); // freopen("out.txt","a+",stdout); int T,N,M;cin>>T; while(T--){ cin>>N; int i; for(i=0; i<N; ++i){ int a;cin>>a; cin>>Tree[a].left>>Tree[a].right; } cin>>M; while(M--)cin>>i>>i;//扔掉数据 inOrderTraversal(0); } return 0; } void inOrderTraversal(int i) { if(i<0)return; inOrderTraversal(Tree[i].left); cout<<i<<endl; inOrderTraversal(Tree[i].right); }