level 6
是CCTV6为什么这么喜欢播这种东西,但是这个电影的确很好看,
还有,我给你发的书你看到了没有?
2011年08月21日 10点08分
10
level 6
这是我构造的树
#include <iostream>
#include <stdlib.h>
#include <vector>
#include <math.h>
using namespace std;
struct tree
{
vector<int> level;
vector<int*> lc;
vector<int*> rc;
};
int main()
{
int n,i,data,m=0;
cin>>n;
struct tree a[n];
input_a_tree:
while(m<n)
{
for (i=0;i<int(pow(2.0,float(m)));i++)
{
cin>>data;
a[m].level.push_back(data);
build_a_tree:
if (m>1)
{
if (i%2==0)
a[m-1].lc.push_back(&(a[m].level.back()));
else
a[m-1].rc.push_back(&(a[m].level.back()));
}
}
m++;
}
for (i=0;i<(pow(2.0,float(m)));i++)
{
a[m-1].lc.push_back(NULL);
a[m-1].rc.push_back(NULL);
}
system ("pause");
return 0;
}
2011年08月21日 10点08分
11