The whole question is set out in the title. The degree of variation is not difficult to determine - 1 or 2, there are no other options, but how to write it in c ++? The implementation of the tree is as follows:

struct tree { int inf; tree*right; tree*left; }; tree * node(int x) { tree*n = new tree; n->inf; n->left = n->right = NULL; return n; } void create(tree *&tr, int n) { int x; if (n > 0) { cin >> x; tr = node(x); int nl = n / 2; int nr = n - nl - 1; create(tr->left, nl); create(tr->right, nr); } } 

    1 answer 1

    For example:

     tr->deg = 0; if (nl>0) //ведь это же условие создания детки, верно? tr->deg++; if (nr>0) tr->deg++; 
    • So wait. My mistake is an incomprehensible task. The node at which you want to calculate the degree is entered from the keyboard. Where to send it? - Karina Krasilnik
    • calculate for the given number nl and nr and do the same - MBo
    • it still does not work - Karina Krasilnik