链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=202
旋转不影响中序遍历,,,坑啊
#include <iostream> #include <cstring> using namespace std; class node { public: int left; int right; }; node tree[20]; void inordervisit(int n) { if(n==-1) return ; inordervisit(tree[n].left); cout<<n<<endl; inordervisit(tree[n].right); } int main() { int T,n; cin>>T; while(T--) { memset(tree,-1,sizeof(tree)); int a,l,r; cin>>n; for(int i=0;i<n;i++) { cin>>a>>l>>r; tree[a].left=l; tree[a].right=r; } int m,x,y; cin>>m; while(m--) { cin>>x>>y; } inordervisit(0); } return 0; }