二叉树应用题——迷阵的出口_i++

二叉树应用题——迷阵的出口_ios_02

二叉树应用题——迷阵的出口_c++_03

//Author:PanDaoxi 
#include <iostream>
using namespace std;
bool tree[100001]; //false=black true=white
int main(){
int n,p;//确定层数
cin>>n;
//5种走法
for(int i=1;i<=5;i++){
p=1; //节点编号
for(int j=1;j<n;j++){
if(tree[p]==false){
tree[p]=true; //变色
p*=2; //更改节点状态
}
else{
tree[p]=false;
p=p*2+1;
}
}
cout<<p<<" ";
}
return 0;
}

二叉树应用题——迷阵的出口_二叉树_04