Language: C++

#include<cstdio>
#define MAX 10000
#define NIL -1

struct Node{
int p.l.r;
};

Node T[MAX];
int n,D[MAX],H[MAX];

main(){
int v,l,r,root=0;

scanf("%d",&n);

for(inti=0;i<n;i++)T[i].p=NIL;

for(int i=0;i<n;i++){
scanf("%d%d%d",&v,&l,&r);
T[v].l=l;
T[v].r=r;
if(l!=NIL)T[l].p=v;
if(r!=NIL)T[r].p=v;
}

for(int i=0;i<n;i++)if(T[i].p==NIL)root=i;

dep(root,0);
height(root);

for(int i=0;i<n;i++)print(i);

return0;
}

void dep(int u,int d){
if(u==NIL)return;
D[u]=d;
dep(T[u].l,d+1);
dep(T[u].r,d+1);
}

int height(int u){
int h1=0,h2=0;
if(T[u].l!=NIL)
h1=height(T[u].l)+1;
if(T[u].r!=NIL)
h2=height(T[u].r+1;
return H[u]=(h1>h2?h1:h2);
}

int Sib(int u){
if(T[u].p==NIL)return NIL;
if(T[T[u].p].l!=u&&T[T[u].p].l!=NIL)
return T[T[u].p].l;
if(T[T[u].p].r!=u&&T[T[u].p].r!=NIL)
return T[T[u].p].r;
return NIL;
}

void print(int u){
printf("node %d: ",u);
printf("p = %d, ,",T[u].p);
printf("sibling = %d, ",Sib(u));
int deg=0;
if(T[u].l!-NIL)deg++;
if(T[u].r!=NIL)deg++;
printf("degree = %d, ",deg);
printf("depth = $d, ",D[u]);
printf("height = %d, ",H[u]);

if(T[u].p==NIL){
printf("root\n");
{else if(T[u].l==NIL&&T[u].r==NIl){
printf("leaf\n");
else{
printf("internal node\n");
}
}

Compiler output:
a.cc:6:5: error: expected ';' at end of member declaration
    6 | int p.l.r;
      |     ^
      |      ;
a.cc:6:6: error: expected unqualified-id before '.' token
    6 | int p.l.r;
      |      ^
a.cc:12:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   12 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:17:5: error: 'inti' was not declared in this scope; did you mean 'int'?
   17 | for(inti=0;i<n;i++)T[i].p=NIL;
      |     ^~~~
      |     int
a.cc:17:12: error: 'i' was not declared in this scope
   17 | for(inti=0;i<n;i++)T[i].p=NIL;
      |            ^
a.cc:21:6: error: 'struct Node' has no member named 'l'
   21 | T[v].l=l;
      |      ^
a.cc:22:6: error: 'struct Node' has no member named 'r'
   22 | T[v].r=r;
      |      ^
a.cc:29:1: error: 'dep' was not declared in this scope
   29 | dep(root,0);
      | ^~~
a.cc:30:1: error: 'height' was not declared in this scope
   30 | height(root);
      | ^~~~~~
a.cc:32:21: error: 'print' was not declared in this scope; did you mean 'printf'?
   32 | for(int i=0;i<n;i++)print(i);
      |                     ^~~~~
      |                     printf
a.cc:34:1: error: 'return0' was not declared in this scope
   34 | return0;
      | ^~~~~~~
a.cc: In function 'void dep(int, int)':
a.cc:40:10: error: 'struct Node' has no member named 'l'
   40 | dep(T[u].l,d+1);
      |          ^
a.cc:41:10: error: 'struct Node' has no member named 'r'
   41 | dep(T[u].r,d+1);
      |          ^
a.cc: In function 'int height(int)':
a.cc:46:9: error: 'struct Node' has no member named 'l'
   46 | if(T[u].l!=NIL)
      |         ^
a.cc:47:16: error: 'struct Node' has no member named 'l'
   47 | h1=height(T[u].l)+1;
      |                ^
a.cc:48:9: error: 'struct Node' has no member named 'r'
   48 | if(T[u].r!=NIL)
      |         ^
a.cc:49:16: error: 'struct Node' has no member named 'r'
   49 | h2=height(T[u].r+1;
      |                ^
a.cc: In function 'int Sib(int)':
a.cc:55:14: error: 'struct Node' has no member named 'l'
   55 | if(T[T[u].p].l!=u&&T[T[u].p].l!=NIL)
      |              ^
a.cc:55:30: error: 'struct Node' has no member named 'l'
   55 | if(T[T[u].p].l!=u&&T[T[u].p].l!=NIL)
      |                              ^
a.cc:56:18: error: 'struct Node' has no member named 'l'
   56 | return T[T[u].p].l;
      |                  ^
a.cc:57:14: error: 'struct Node' has no member named 'r'
   57 | if(T[T[u].p].r!=u&&T[T[u].p].r!=NIL)
      |              ^
a.cc:57:30: error: 'struct Node' has no member named 'r'
   57 | if(T[T[u].p].r!=u&&T[T[u].p].r!=NIL)
      |                              ^
a.cc:58:18: error: 'struct Node' has no member named 'r'
   58 | return T[T[u].p].r;
      |                  ^
a.cc: In function 'void print(int)':
a.cc:67:9: error: 'struct Node' has no member named 'l'
   67 | if(T[u].l!-NIL)deg++;
      |         ^
a.cc:67:10: error: expected ')' before '!' token
   67 | if(T[u].l!-NIL)deg++;
      |   ~      ^
      |          )
a.cc:68:9: error: 'struct Node' has no member named 'r'
   68 | if(T[u].r!=NIL)deg++;
      |         ^
a.cc:75:2: error: expected '}' before 'else'
   75 | {else if(T[u].l==NIL&&T[u].r==NIl){
      | ~^~~~
a.cc:75:2: error: expected '}' before 'else'
a.cc:73:16: note: to match this '{'
   73 | if(T[u].p==NIL){
      |                ^
a.cc:75:15: error: 'struct Node' has no member named 'l'
   75 | {else if(T[u].l==NIL&&T[u].r==NIl){
      |               ^
a.cc:75:28: error: 'struct Node' has no member named 'r'
   75 | {else if(T[u].l==NIL&&T[u].r==NIl){
      |                            ^
a.cc:75:31: error: 'NIl' was not declared in this scope; did you mean 'NIL'?
   75 | {else if(T[u].l==NIL&&T[u].r==NIl){
      |                               ^~~
      |                               NIL
a.cc:77:1: error: expected '}' before 'else'
   77 | else{
      | ^~~~
a.cc:75:35: note: to match this '{'
   75 | {else if(T[u].l==NIL&&T[u].r==NIl){
      |                                   ^