void first_queue(node n,node N[]){ if (n.value == -1) { return; } int a; if(n.left != -1)queue1[top1++] = n.left; if(n.right != -1)queue1[top1++] = n.right; a = queue1[rear1++]; first_queue(N[a],N); }
double bm_queue_node(tbb::flow::graph& g, int nIter) { tbb::flow::queue_node<my_type> first_queue(g); my_type v(nSize); tbb::tick_count t0 = tbb::tick_count::now(); //using queue_node for (int i = 0; i < nIter; ++i) first_queue.try_put(v); g.wait_for_all(); return (tbb::tick_count::now() - t0).seconds(); }
int main(int argc, char const *argv[]) { node N[10001]; int n; scanf("%d",&n); int a,b,c; for (int i = 1; i <= n; i++){ // N[i].id = 0; N[i].value = 0; N[i].left = 0; N[i].right = 0; N[i].father = -2; } N[0].value = 0; for (int i = 0; i < n; i++) { scanf("%d %d %d", &a, &b, &c); N[a].value=a; if(b != -1){ N[a].left = b; N[b].father = a; } if(c != -1){ N[a].right = c; N[c].father = a; } } node nn; nn = find_root(n,N); first_queue(nn,N); // nn.id = 1; /* tot=0; pre_order(nn,N); display(n); tot=0; in_order(nn,N); display(n); tot=0; post_order(nn,N); display(n); */ // int num[10001]; // for(int i = 1; i < 10001; ++i){ // num[i] = -1; // } // num[1]=nn.value; // level_order(nn,N,num); // for (int i = 0; i < n; ++i) // { // printf("%d %d %d\n", N[i].value, N[i].left, N[i].right); // } // for(int i = 1,j = 1; i < 10001; ++i){ // if(num[i] != -1 & num[i] != 0){ // answer[j++] = num[i]; // } // } // display(n); return 0; }