题目链接:
一棵树左旋或者右旋,树的中序遍历保持不变
#include#include #include using namespace std;int ls[25];int rs[25]; int n;void print(int id){ if(id == -1 || id >= n) return ; print(ls[id]); cout< < >t; while(t--) { memset(ls, 0, sizeof(ls)); memset(rs, 0, sizeof(rs)); int a, b, c; cin>>n; for(int i=0; i >a>>b>>c; ls[a]= b; rs[a] = c; } int m; cin>>m; while(m--) cin>>a>>b; print(0); cout<