Language: C++

void degree(int);
int height(int);
data A[25];
int B[25];
int main(){
  int N,i,id,l,r,root;

  scanf("%d",&N);

  for(i=0;i<N;i++) {
    A[i].parent=NIL;
    A[i].sibling=NIL;
  }
    for(i=0;i<N;i++){
    scanf("%d%d%d",&id,&l,&r);
    
    A[i].left=l;
    A[i].right=r;
    if(l!=NIL) A[l].parent=id;
    if(r!=NIL) A[r].parent=id;
    }
    for(i=0;i<N;i++){
      if(A[i].parent==-1) root=i;
	}
    printf("%d\n",root);
    preparse(root);
  sibling(root,A[root].right,A[root].left);
  degree(root);
  height(root);
  
  for(i=0;i<N;i++){ printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i,A[i].parent,A[i].sibling,A[i].degree,A[i].depth,A[i].height);  
    if(A[i].parent==NIL) printf("root\n");
    else if(A[i].right==NIL&&A[i].left==NIL) printf("leaf\n");
    else if((A[i].right!=NIL&&A[i].left==NIL)||(A[i].right==NIL&&A[i].left!=NIL)||(A[i].right!=NIL&&A[i].left!=NIL))printf("internal node\n");
  
  }
  return 0;
}

void preparse(int u){
  static int count;
 
  if(u==NIL) return;

  A[u].depth=count;
  count++;
  preparse(A[u].left);
  preparse(A[u].right);
  count--;
}

void sibling(int u,int r,int l){
  int i;

  if(u==NIL) return;
  if(A[u].left!=NIL && A[u].right!=NIL) {
    A[l].sibling=A[u].right;   
    A[r].sibling=A[u].left;
  }

  sibling(A[u].left,A[l].right,A[l].left);
  sibling(A[u].right,A[r].right,A[r].left);
  
}
  
void degree(int u){
  if(u==NIL) return;
  if(A[u].left!=NIL && A[u].right!=NIL) A[u].degree=2;
  else if((A[u].left==NIL && A[u].right!=NIL) || (A[u].left!=NIL && A[u].right==NIL)) A[u].degree=1;
  else A[u].degree=0;

  degree(A[u].left);
  degree(A[u].right);
}

int height(int u){
  int h1=0,h2=0;
  if(A[u].left!=NIL) h1=height(A[u].left)+1;
  if(A[u].right!=NIL) h2=height(A[u].right)+1;

if(h1>h2) B[u]=h1;
      else B[u]=h2;
 A[u].height=B[u];
 
 return B[u]; 
}

Compiler output:
a.cc:3:1: error: 'data' does not name a type
    3 | data A[25];
      | ^~~~
a.cc: In function 'int main()':
a.cc:8:3: error: 'scanf' was not declared in this scope
    8 |   scanf("%d",&N);
      |   ^~~~~
a.cc:11:5: error: 'A' was not declared in this scope
   11 |     A[i].parent=NIL;
      |     ^
a.cc:11:17: error: 'NIL' was not declared in this scope
   11 |     A[i].parent=NIL;
      |                 ^~~
a.cc:17:5: error: 'A' was not declared in this scope
   17 |     A[i].left=l;
      |     ^
a.cc:19:11: error: 'NIL' was not declared in this scope
   19 |     if(l!=NIL) A[l].parent=id;
      |           ^~~
a.cc:20:11: error: 'NIL' was not declared in this scope
   20 |     if(r!=NIL) A[r].parent=id;
      |           ^~~
a.cc:23:10: error: 'A' was not declared in this scope
   23 |       if(A[i].parent==-1) root=i;
      |          ^
a.cc:25:5: error: 'printf' was not declared in this scope
   25 |     printf("%d\n",root);
      |     ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 | void degree(int);
a.cc:26:5: error: 'preparse' was not declared in this scope
   26 |     preparse(root);
      |     ^~~~~~~~
a.cc:27:16: error: 'A' was not declared in this scope
   27 |   sibling(root,A[root].right,A[root].left);
      |                ^
a.cc:27:3: error: 'sibling' was not declared in this scope
   27 |   sibling(root,A[root].right,A[root].left);
      |   ^~~~~~~
a.cc:32:21: error: 'NIL' was not declared in this scope
   32 |     if(A[i].parent==NIL) printf("root\n");
      |                     ^~~
a.cc: In function 'void preparse(int)':
a.cc:43:9: error: 'NIL' was not declared in this scope
   43 |   if(u==NIL) return;
      |         ^~~
a.cc:45:3: error: 'A' was not declared in this scope
   45 |   A[u].depth=count;
      |   ^
a.cc: In function 'void sibling(int, int, int)':
a.cc:55:9: error: 'NIL' was not declared in this scope
   55 |   if(u==NIL) return;
      |         ^~~
a.cc:56:6: error: 'A' was not declared in this scope
   56 |   if(A[u].left!=NIL && A[u].right!=NIL) {
      |      ^
a.cc:56:17: error: 'NIL' was not declared in this scope
   56 |   if(A[u].left!=NIL && A[u].right!=NIL) {
      |                 ^~~
a.cc:61:11: error: 'A' was not declared in this scope
   61 |   sibling(A[u].left,A[l].right,A[l].left);
      |           ^
a.cc: In function 'void degree(int)':
a.cc:67:9: error: 'NIL' was not declared in this scope
   67 |   if(u==NIL) return;
      |         ^~~
a.cc:68:6: error: 'A' was not declared in this scope
   68 |   if(A[u].left!=NIL && A[u].right!=NIL) A[u].degree=2;
      |      ^
a.cc:68:17: error: 'NIL' was not declared in this scope
   68 |   if(A[u].left!=NIL && A[u].right!=NIL) A[u].degree=2;
      |                 ^~~
a.cc:72:10: error: 'A' was not declared in this scope
   72 |   degree(A[u].left);
      |          ^
a.cc: In function 'int height(int)':
a.cc:78:6: error: 'A' was not declared in this scope
   78 |   if(A[u].left!=NIL) h1=height(A[u].left)+1;
      |      ^
a.cc:78:17: error: 'NIL' was not declared in this scope
   78 |   if(A[u].left!=NIL) h1=height(A[u].left)+1;
      |                 ^~~
a.cc:79:6: error: 'A' was not declared in this scope
   79 |   if(A[u].right!=NIL) h2=height(A[u].right)+1;
      |      ^
a.cc:79:18: error: 'NIL' was not declared in this scope
   79 |   if(A[u].right!=NIL) h2=height(A[u].right)+1;
      |                  ^~~
a.cc:83:2: error: 'A' was not declared in this scope
   83 |  A[u].height=B[u];
      |  ^