criyle/codenet-compile-errors huggingface dataset:
Language: C

#include<stdio.h>
#include <stdlib.h>
#define N 100000

typedef struct{
  int p;
  int k;
  int *child;
}Node;

int depth_count(Node*,int,int);

int main(){
  int num,i,j,k,number;
  Node node[N]; 
  
  scanf("%d",&num);

  for(i=0; i<num; i++){
    scanf("%d",&number);
    scanf("%d",&node[i].k);
    node[i].child = (int *)malloc(sizeof(int) * node[i].k);
    for(j=0; j<node[i].k; j++){
      scanf("%d",&node[i].child[j]);
      node[node[i].child[j]].p = i;
    }
    node[0].p = -1;
  }
  
  
  for(i=0; i<num; i++){
    printf("node %d: parent= %d, ",i,node[i].p);
    printf("depth = %d, ",depth_count(node,i,0));
    
    if(node[i].p==-1) printf("root, [");
    else if(node[i].k==0) printf("leaf, [");
    else printf("internal node, [");
    
    for(j=0; j<node[i].k; j++){
      printf("%d",node[i].child[j]);
      if(j+1<node[i].k) printf(", ");
    }
    printf("]\n");
  }
  

  return 0;
}

Compiler output:
/usr/bin/ld: /tmp/ccvijoqq.o: in function `main':
main.c:(.text+0x1ba): undefined reference to `depth_count'
collect2: error: ld returned 1 exit status
Language: C

#include<stdio.h>

#define MAX 100004
#define NIL -1

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

struct Node T[MAX];

int dep=1;

int depth(int d){
  if(T[d].p==NIL) return 0;
  if(T[T[d].p].p!=NIL){
    dep++;
    depth(T[d].p);
  }
  return dep;
}

void print(int q){
  int i;
  printf("node %d: ",q);
  printf("parent = %d, ",T[q].p);
  printf("depth = %d, ",depth(q));

  if(T[q].p==NIL){
    printf("root, [");
    if(T[q].l!=NIL){
      printf("%d",T[q].l);
      while(T[T[q].l].r!=NIL){
	printf(", %d",T[T[q].l].r);
	T[q].l=T[T[q].l].r;
      }
    }
    printf("]\n");
  }

  else if(T[q].p!=NIL && T[q].l!=NIL){
    printf("internal node, [%d",T[q].l);
    while(T[T[q].l].l!=NIL){
      printf(", %d",T[T[q].l].r);
      T[q].l+T[T[q].l].r;
    }
    printf("]\n");
  }

  else if(T[q].l==NIL){
    printf("leaf, []\n");
  }
}
 

Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C

#include <stdio.h>
#define N 100005

int main(){

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

  struct Node T[MAX];


  int depth(int);
  int child(int);

  int main(){
    int i, j,n,a,b,c,m;
  scanf("%d", &n);

  for(i = 0; i < n; i++){
   T[i].p = NIL;
   T[i].l = NIL;
   T[i].r = NIL;
  }
  for(i = 0; i < n; i++){
    scanf("%d %d", &a, &b);
    for(j = 0; j < b; j++){
      scanf("%d", &c); 
      T[c].p = a;
      if(j == 0){
        T[a].l = c;
      } else {
        T[m].r = c;
      }
      m = c;
    }
  }
   
  for(i = 0; i < n; i++){
    printf("node %d: parent = %d, depth = %d, ", i, T[i].p, depth(i)); 
    if(T[i].p == NIL){
      printf("root, [");
    } else if(T[i].l == NIL){
      printf("leaf, [");
    } else{
    printf("internal node, [");
    }
    child(T[i].l);
    printf("]\n");
  }
  return 0;
}
   
  int depth(int x1){
  int a;  
  if(T[x1].p == NIL){
    return 0;
  } else{
    a = depth(T[x1].p) + 1;
    return a;
  }
}
   
int child(int x2){
  if(x2==NIL){
    return 0;
  } else {
    if(T[x2].r == NIL){
      printf("%d", x2);
    } else{
      printf("%d, ", x2);
      child(T[x2].r);
    }
  }
}

Compiler output:
main.c: In function 'main':
main.c:10:17: error: 'MAX' undeclared (first use in this function)
   10 |   struct Node T[MAX];
      |                 ^~~
main.c:10:17: note: each undeclared identifier is reported only once for each function it appears in
main.c: In function 'main':
main.c:21:13: error: 'NIL' undeclared (first use in this function)
   21 |    T[i].p = NIL;
      |             ^~~
main.c: In function 'main':
main.c:54:7: error: static declaration of 'depth' follows non-static declaration
   54 |   int depth(int x1){
      |       ^~~~~
main.c:13:7: note: previous declaration of 'depth' with type 'int(int)'
   13 |   int depth(int);
      |       ^~~~~
main.c: In function 'depth':
main.c:56:17: error: 'NIL' undeclared (first use in this function)
   56 |   if(T[x1].p == NIL){
      |                 ^~~
main.c: In function 'main':
main.c:64:5: error: static declaration of 'child' follows non-static declaration
   64 | int child(int x2){
      |     ^~~~~
main.c:14:7: note: previous declaration of 'child' with type 'int(int)'
   14 |   int child(int);
      |       ^~~~~
main.c: In function 'child':
main.c:65:10: error: 'NIL' undeclared (first use in this function)
   65 |   if(x2==NIL){
      |          ^~~
main.c: In function 'main':
main.c:75:1: error: expected declaration or statement at end of input
   75 | }
      | ^
Language: C

#include <stdio.h>

#define N 100000

typedef struct{
  int k;
  int c[N];
  int depth = 1;
   
} Tree;

int main(){

  int n,i,id[N],j;
  Tree tr[N];

  scanf("%d",&n);

  for(i=0 ; i<n ; i++){
    scanf("%d %d",&id[i],&tr[id[i]].k);
    for(j=0 ; j<tr[id[i]].k ; j++){
      scanf("%d",&tr[id[i]].c[j]);
    }
  }

  for(i=0 ; i<n ; i++){
  printf("node %d: parent = %d , depth = %d ,"id[i],)


}

Compiler output:
main.c:8:13: error: expected ':', ',', ';', '}' or '__attribute__' before '=' token
    8 |   int depth = 1;
      |             ^
main.c: In function 'main':
main.c:27:47: error: expected ')' before 'id'
   27 |   printf("node %d: parent = %d , depth = %d ,"id[i],)
      |         ~                                     ^~
      |                                               )
main.c:27:54: error: expected ';' before '}' token
   27 |   printf("node %d: parent = %d , depth = %d ,"id[i],)
      |                                                      ^
      |                                                      ;
......
   30 | }
      | ~                                                     
main.c:30:1: error: expected declaration or statement at end of input
   30 | }
      | ^
Language: C

#include<stdio.h>
#define N 100000

struct Node{
  int parent;
  int left;
  int right;
};

struct Node T[N];
int count = 0;

int depth(int id){
  if(T[id].parent == -1){
    return count;
  }

  else{
    count++;
    return depth(T[id].parent);
  }
}


void degree(int id){
  if(id != -1){
    if(count != 0){
      printf(", ");
    }
    print("%d",id);
    count++;
    degree(T[id].right);
  }
}



int main(){
  int i,j,n,left,right,node,child,m;


  scanf("%d",&n);

  for(i=0 ; i<n ; i++){
    T[i].parent = -1;
    T[i].left = -1;
    T[i].right = -1;
  }

  for(i=0 ; i<n ; i++){
    scanf("%d%d",&node,&m);
    for(j=0 ; j<m ; j++){
      scanf("%d",&child);
      T[child].parent = node;
      if(j != 0)T[left].right = child;
      else T[node].left = child;
      left = child;
    }
  }

  for(i=0;i<n;i++){
    count = 0;
   
    printf("node %d: parent = %d, depth = %d, ",i,T[i].parent,depth(i));
    if(T[i].parent == -1) printf("root, [");
    else if(T[i].left == -1) printf("leaf, [");
    else  printf("internal node, [");
    count = 0;
    degree(T[i].left);
    printf("]\n");
  }
  return 0;
}

Compiler output:
main.c: In function 'degree':
main.c:30:5: error: implicit declaration of function 'print'; did you mean 'printf'? [-Wimplicit-function-declaration]
   30 |     print("%d",id);
      |     ^~~~~
      |     printf
Language: C


#include<stdio.h>
#define MAX 100000
#define NIL -1

struct Node{int p,l,r;};
struct Node T[MAX];
int n,D[MAX];

void print(int u){
  int i,c;
  printf("node=%d: ",u);
  printf("parent=%d,",T[u].p);
  printf("depth=%d,",D[u]);

  if(T[u].p == NIL)printf(" root,");
  else if(T[u].l == NIL)printf(" leaf,");
  else printf(" internal node,");
  printf("[");
  for(i = 0 , c = T[u].l;c != NIL ;i++,c=T[c].r){
    if(i)printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}
int setDepth(int u,int p){
  D[u] = p;
  if(T[u].r != NIL)setDepth(T[u].r,p);
  if(T[u].l != NIL)setDepth(T[u].l,p + 1);
}
int main(){
  int i,j,v,l=0,r,d,c;
  scanf("%d",&n);
  for(i = 0; i < n ; i++ ){
    T[i].p = T[i].l = T[i].r = NIL;
  }
  for(i = 0 ; i < n ; i++ ){
    scanf("%d %d",&v,&d);
    for(j = 0; j < d ; j++){
      scanf("%d",&c);
      if( j == 0 )T[v].l = c;
      else T[l].r = c;
      l=c;
      T[c].p=v;
    }
  }
  for( i = 0 ; i < n ; i++ ){
    if( T[i].p==NIL)r = i;
  }
  setDepth(r,0);
  for( i = 0 ; i < n ; i++ ){
    print(i);
  }
  return 0;

Compiler output:
main.c: In function 'main':
main.c:54:3: error: expected declaration or statement at end of input
   54 |   return 0;
      |   ^~~~~~
Language: C

#include<stdio.h>

typedef struct node{

  int num;
  int depth;
  int parent;
  int br;
  int child;

}Node;

void nodegene( Node*);

void nodegene( Node* node){

  node -> depth = 0;
  node -> child = -1;
  node -> br = -1;
  node -> parent = -1;

}


int main(){

  int i, j, m, n, l, nod, d, degree,br;
  Node node[100001];
  Node c;
  scanf("%d",&m);

  for( i =0; i < m; i++)nodegene(&node[i]);

  for( i = 0; i < m; i++){

    scanf("%d%d", &n, &nod);

    for( j = 0; j < nod; j++){

      scanf("%d", &degree);

      if( node[n].child == -1){
	node[n].child = degree;
	node[degree].parent = n;
      }
      else if(node[n].child != -1){
	l = node[n].child;
	while( node[l].br != -1) l = node[l].br;

	node[l].br = degree;
	node[degree].parent = n;
      }
      node[degree].depth = node[n].depth + 1;
    }
  }

  for( i = 0; i < m; i++){

    printf("node %d: parent = %d, depth = %d, ", i, node[i].parent, node[i].depth);

    if(node[i].child == -1 && node[i].parent != -1)
      printf("leaf, ");
    else if(node[i].parent == -1 && node[i].children != -1)
      printf("root, " );
    else 
      printf("internal node, " );

    printf("[");

    if(node[i].child != -1){

      printf("%d",node[i].child);

      br = node[i].child;

      while(1){
	if(node[br].br == -1)
	  break;
	printf(", %d",node[br].br);
	br = node[br].br;
      }
    }

    printf("]\n");
  }
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:63:45: error: 'Node' {aka 'struct node'} has no member named 'children'; did you mean 'child'?
   63 |     else if(node[i].parent == -1 && node[i].children != -1)
      |                                             ^~~~~~~~
      |                                             child
Language: C

#include <stdio.h>
#define MAX 100000
#define NTL - 1;

typedef struct Node{
  int p,l,r;
}Node;

Node T[MAX];

int depht(int);
void print_degree(int);

int main(){

  int n,i,j,node,degree,child,sibling;

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

  for(i = 0; i < n; i++){
    scanf("%d%d",&node,&degree);
    for(j = 0; j < degree; j++){
      scanf("%d",&child);
      T[child].p = node;
      if(j == 0){
        T[node].l = child;
      }
      sibling = child;
    }
  }

  for(i = 0; i < n; i++){
    printf("node %d: parent = %d, deepth = %d, ",i,T[i].p,depth(i));

    if(T[i].p == NIL){
      printf("root, [");
    }
    else if(T[i].l == NIL){
      printf("leaf, [");
    }
    else{
      printf("internal node, [");
    }
    print_degree(T[i].l);
    printf("]\n");
  }

  return 0;
}

int depth(int node){
  if(T[node].p == NIL){
    return 0;
  }
  else {
    return depth(T[node].p) + 1;
  }
}

void print_degree(int i){
  if(i != NIL){
    if(T[i].r == NIL){
      printf("%d",i);
    }
    else printf("%d, ",i);
    printf_degree(T[i].r);
  }
}

Compiler output:
main.c: In function 'main':
main.c:20:14: error: 'NIL' undeclared (first use in this function); did you mean 'NTL'?
   20 |     T[i].p = NIL;
      |              ^~~
      |              NTL
main.c:20:14: note: each undeclared identifier is reported only once for each function it appears in
main.c:38:59: error: implicit declaration of function 'depth'; did you mean 'depht'? [-Wimplicit-function-declaration]
   38 |     printf("node %d: parent = %d, deepth = %d, ",i,T[i].p,depth(i));
      |                                                           ^~~~~
      |                                                           depht
main.c: In function 'depth':
main.c:57:19: error: 'NIL' undeclared (first use in this function); did you mean 'NTL'?
   57 |   if(T[node].p == NIL){
      |                   ^~~
      |                   NTL
main.c: In function 'print_degree':
main.c:66:11: error: 'NIL' undeclared (first use in this function); did you mean 'NTL'?
   66 |   if(i != NIL){
      |           ^~~
      |           NTL
main.c:71:5: error: implicit declaration of function 'printf_degree'; did you mean 'print_degree'? [-Wimplicit-function-declaration]
   71 |     printf_degree(T[i].r);
      |     ^~~~~~~~~~~~~
      |     print_degree
Language: C

#include<stdio.h>
#include<stdlib.h>

#define MAX 100004
#define NIL -1

struct Node{
  int p;
  int num;
  int depth;
  int* child;
};

struct Node T[MAX];



void depth(int d,int dep){
  T[d].depth=dep;
  int i;
  for(i=0;i<T[d].num;i++){
    depth(T[d].child[i],dep+1);
  }
}

void print(int q){

  int i;
  printf("node %d: ",q);

  printf("parent = %d, ",T[q].p);

  printf("depth = %d, ",T[q].depth);


  if(T[q].p==NIL){
    printf("root,[%d",T[q].child[0]);
    for(i=1;i<T[q].num;i++){
	printf(", %d",T[q].child[i]);
      }
    printf("]\n");
    }

  if(T[q].p!=NIL && T[q].num!=0){
    printf("internal node, [%d",T[q].child[0]);
    for(i=1;i<T[q].num;i++){
      printf(", %d",T[q].child[i]);
    }
    printf("]\n");
  }

  else if(T[q].num==0){
    printf("leaf, []\n");
  }
}
 
int main(){
  int i,j,n,nn,z,c,b,a;

  scanf("%d",&n);

  for(i=0;i<n;i++)
    T[i].p=-1;

  for(i=0;i<n;i++){
    scanf("%d%d",&nn,&z);
    T[nn].num=z;
    T[nn].child = (int*)malloc( z * sizeof(int) );

    for(j=0;j<z;j++){
      scanf("%d",&T[nn].child[j]);
      T[ T[nn].child[j] ].p=nn;
    }
  }

Compiler output:
main.c: In function 'main':
main.c:74:3: error: expected declaration or statement at end of input
   74 |   }
      |   ^
Language: C

#include<stdio.h>

typedef struct node{

  int num;
  int depth;
  int parent;
  int br;
  int child;

}Node;

void nodegene( Node*);

int depth(int);

void nodegene( Node* node){

  node -> depth = 0;
  node -> child = -1;
  node -> br = -1;
  node -> parent = -1;

}

int depth(int k){
  int dep = 0;
  for(dep = 0 ; node[k].parent != -1 ; dep++){
    k = node[k].parent;
  }
  return dep;
}

int main(){

  int i, j, m, n, l, nod, d, degree,br;
  Node node[100001];
  Node c;
  scanf("%d",&m);

  for( i =0; i < m; i++)nodegene(&node[i]);

  for( i = 0; i < m; i++){

    scanf("%d%d", &n, &nod);

    for( j = 0; j < nod; j++){

      scanf("%d", &degree);

      if( node[n].child == -1){
	node[n].child = degree;
	node[degree].parent = n;     
      }
      else if(node[n].child != -1){
	l = node[n].child;
	while( node[l].br != -1) l = node[l].br;

	node[l].br = degree;
	node[degree].parent = n;
      }
    }
  }

  for( i = 0; i < m; i++){

    printf("node %d: parent = %d, depth = %d, ", i, node[i].parent, node[i].depth(i));

    if(node[i].child == -1 && node[i].parent != -1)
      printf("leaf, ");
    else if(node[i].parent == -1)
      printf("root, " );
    else if(node[i].child != -1 && node[i].parent != -1)
      printf("internal node, " );

    printf("[");

    if(node[i].child != -1){

      printf("%d",node[i].child);

      br = node[i].child;

      while(1){
	if(node[br].br == -1)
	  break;
	printf(", %d",node[br].br);
	br = node[br].br;
      }
    }

    printf("]\n");
  }
  return 0;
}

Compiler output:
main.c: In function 'depth':
main.c:28:17: error: 'node' undeclared (first use in this function)
   28 |   for(dep = 0 ; node[k].parent != -1 ; dep++){
      |                 ^~~~
main.c:28:17: note: each undeclared identifier is reported only once for each function it appears in
main.c: In function 'main':
main.c:67:69: error: called object is not a function or function pointer
   67 |     printf("node %d: parent = %d, depth = %d, ", i, node[i].parent, node[i].depth(i));
      |                                                                     ^~~~
Language: C

#include<stdio.h>

typedef struct node{

  int num;
  int depth;
  int parent;
  int br;
  int child;

}Node;

void nodegene( Node*);

int depth(int);

void nodegene( Node* node){

  node -> depth = 0;
  node -> child = -1;
  node -> br = -1;
  node -> parent = -1;

}

int depth(int k){
  int dep = 0;
  for(dep = 0 ; node[k].parent != -1 ; dep++){
    k = node[k].parent;
  }
  return dep;
}

int main(){

  int i, j, m, n, l, nod, d, degree,br;
  Node node[100001];
  Node c;
  scanf("%d",&m);

  for( i =0; i < m; i++)nodegene(&node[i]);

  for( i = 0; i < m; i++){

    scanf("%d%d", &n, &nod);

    for( j = 0; j < nod; j++){

      scanf("%d", &degree);

      if( node[n].child == -1){
	node[n].child = degree;
	node[degree].parent = n;     
      }
      else if(node[n].child != -1){
	l = node[n].child;
	while( node[l].br != -1) l = node[l].br;

	node[l].br = degree;
	node[degree].parent = n;
      }
    }
  }

  for( i = 0; i < m; i++){

    printf("node %d: parent = %d, depth = %d, ", i, node[i].parent, depth(i));

    if(node[i].child == -1 && node[i].parent != -1)
      printf("leaf, ");
    else if(node[i].parent == -1)
      printf("root, " );
    else if(node[i].child != -1 && node[i].parent != -1)
      printf("internal node, " );

    printf("[");

    if(node[i].child != -1){

      printf("%d",node[i].child);

      br = node[i].child;

      while(1){
	if(node[br].br == -1)
	  break;
	printf(", %d",node[br].br);
	br = node[br].br;
      }
    }

    printf("]\n");
  }
  return 0;
}

Compiler output:
main.c: In function 'depth':
main.c:28:17: error: 'node' undeclared (first use in this function)
   28 |   for(dep = 0 ; node[k].parent != -1 ; dep++){
      |                 ^~~~
main.c:28:17: note: each undeclared identifier is reported only once for each function it appears in
Language: C

int tree(int);
void child(int);

int main()
{
  int i,j,n,k,id,c,d,a;

  scanf("%d",&n);
  for(i = 0; i < n ;i++){
    T[i].p = -1;
    T[i].l = -1;
    T[i].r = -1;
  }

  for(i = 0; i < n; i++){ 
    scanf("%d%d",&id,&k);
    for(j = 1; j <= k; k++){
      scanf("%d",&c);
      T[c].p = id;
      if(j == 1) T[id].l = c;
      else T[a].r = c;
      a = c;
    }
  }


  for(i = 0; i < n; i++){
    printf("node %d: parent = %d, depth = %d, ",i,T[i].p,tree(i));

    if(T[i].p == -1) printf("root, [");
    else if(T[i].l == -1) printf("leaf, [");
    else printf("internal node, [");

    child(i);
  }
  return 0;
}

int tree(int i){

  int d = 0;

  while(T[i].p != -1){
    i = T[i].p;
    d++;
  }
  return d;
}

void child(int i){

  int a;

  a = T[i].l;

  while(a != -1){
    printf("%d",a);
    a = T[a].r;
    if(a != -1) printf(", ");
  }
  printf("]");
}

Compiler output:
main.c: In function 'main':
main.c:8:3: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
    8 |   scanf("%d",&n);
      |   ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | int tree(int);
main.c:8:3: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
    8 |   scanf("%d",&n);
      |   ^~~~~
main.c:8:3: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:10:5: error: 'T' undeclared (first use in this function)
   10 |     T[i].p = -1;
      |     ^
main.c:10:5: note: each undeclared identifier is reported only once for each function it appears in
main.c:28:5: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
   28 |     printf("node %d: parent = %d, depth = %d, ",i,T[i].p,tree(i));
      |     ^~~~~~
main.c:28:5: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:28:5: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:28:5: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c: In function 'tree':
main.c:43:9: error: 'T' undeclared (first use in this function)
   43 |   while(T[i].p != -1){
      |         ^
main.c: In function 'child':
main.c:54:7: error: 'T' undeclared (first use in this function)
   54 |   a = T[i].l;
      |       ^
main.c:57:5: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
   57 |     printf("%d",a);
      |     ^~~~~~
main.c:57:5: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:61:3: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
   61 |   printf("]");
      |   ^~~~~~
main.c:61:3: note: include '<stdio.h>' or provide a declaration of 'printf'
Language: C

#include<stdio.h>
#define M 100000

typedef struct{
  int id;
  int k;
  int c[20];
  int p;
  int l;
  int dep;
}Node;

Node T[M];

void depth(int,int);

int main(){
  int n,i,j;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
   T[i].p=-1;
   T[i].l=-1;
  }
  for(i=0;i<n;i++){

    scanf("%d",&T[i].id);

    scanf("%d",&T[T[i].id].k);

    for(j=0;j<T[T[i].id].k;j++){

      scanf("%d",&T[T[i].id].c[j]);

      T[T[T[i].id].c[j]].p= T[i].id;
      T[T[i].id].l=T[T[i].id].c[0];
    }
  }
  for(i=0;i<n;i++){
    if(T[T[i].id].p==-1) T[T[i].id].dep=0;
    depth(T[i].id,T[T[i].id].dep);
  } 

  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, " ,i,T[i].p,T[i].dep);
   
    if(T[i].p==-1) printf("root, ");
    else if(T[i].k==0) printf("leaf, ");
    else printf("internal node, ");
  
    printf("[");
    for(j=0;j<T[i].k-1;j++){
      (j==T[i].k-1)printf("%d",T[i].c[j]);
      printf("%d, ",T[i].c[j]);
    }
     printf("%d]\n",T[i].c[T[i].k-1]);
  }
  return 0;
}

void depth(int id,int count){
  int j;
  T[id].dep=count;
  if(T[id].l==-1)return;
  else for(j=0;j<T[id].k;j++){
      depth(T[id].c[j],T[id].dep+1);
	    }
}

Compiler output:
main.c: In function 'main':
main.c:53:20: error: expected ';' before 'printf'
   53 |       (j==T[i].k-1)printf("%d",T[i].c[j]);
      |                    ^~~~~~
      |                    ;
Language: C

#include<stdio.h>
#include<stdlib.h>

typedef struct{
  int parent,left,right;
}Node;

void depth(int,int,Node *,int *);

int main(){
 
	int n, *D, *H;
	int i,j,d,c,v,root,left,right;
 
	scanf("%d",&n);

	Node *T;
	T=(Node *)malloc(sizeof(Node)*n);
	D=(int *)malloc(sizeof(int)*n);
	H=(int *)malloc(sizeof(int)*n);
    for(i = 0; i<n; i++){
      T[i].parent = T[i].left = T[i].right =-1;
    }
     
    for(i=0; i<n; i++){
      scanf("%d %d",&v,&d);
      for(j=0; j<d; j++){
    scanf("%d",&c);
    if(j==0)
      T[v].left = c;
    else
      T[left].right = c;
    left = c;
    T[c].parent = v;
      }
    }
 
    for(i=0; i<n; i++){
      if(T[i].parent==-1) root = i;
    }
 
    depth(root,0,T,D);
    
 
    for(i=0; i<n; i++){
    	
	printf("node %d: ",i);
	printf("parent = %d, ", T[i].parent);
 	printf("depth = %d, ",D[i]);
 
 	if(T[i].parent==-1){
    printf("root, ");
  	}
  	else if(T[i].left==-1){
    	printf("leaf, ");
  	}
  	else{
    	printf("internal node, ");
  	}
 
  	printf("[");
 
  	for(j=0, c=T[i].left; c!=-1; j++,c=T[c].right){
    	if(j)
      	printf(", ");
    }	
    printf("%d",c);
	}
 
  	printf("]\n");
    
 
    return 0;
}
void depth(int u, int d,int *T,int *D){
  D[u] = 0;
 
  if(T[u]->right != -1) depth(T[u]->right, d,T,D);
  if(T[u]->left != -1) depth(T[u]->left, d+1,T,D);
}

Compiler output:
main.c:75:6: error: conflicting types for 'depth'; have 'void(int,  int,  int *, int *)'
   75 | void depth(int u, int d,int *T,int *D){
      |      ^~~~~
main.c:8:6: note: previous declaration of 'depth' with type 'void(int,  int,  Node *, int *)'
    8 | void depth(int,int,Node *,int *);
      |      ^~~~~
main.c: In function 'depth':
main.c:78:10: error: invalid type argument of '->' (have 'int')
   78 |   if(T[u]->right != -1) depth(T[u]->right, d,T,D);
      |          ^~
main.c:78:35: error: invalid type argument of '->' (have 'int')
   78 |   if(T[u]->right != -1) depth(T[u]->right, d,T,D);
      |                                   ^~
main.c:79:10: error: invalid type argument of '->' (have 'int')
   79 |   if(T[u]->left != -1) depth(T[u]->left, d+1,T,D);
      |          ^~
main.c:79:34: error: invalid type argument of '->' (have 'int')
   79 |   if(T[u]->left != -1) depth(T[u]->left, d+1,T,D);
      |                                  ^~
Language: C

#include <stdio.h>
#include <stdlib.h>

typedef struct s{
  int key;
  int *left;
  int **right;
  int *parent;
}Node;

Node root;
Node *T = &root;
int depth=0;

int main(void){
  int i,j,n,k,d;

  // input 
  scanf("%d",&n);

  while(T->left != 0){
    scanf("%d %d ",&T->left,&k); 

    if(k == 0){
      T[i].left = NULL;
      T[i].right = (int *)malloc(sizeof(int));
      T[i].right = NULL;
      continue;
    }

    T[i].right = (int *)malloc(sizeof(int) * k-1);

    scanf("%d ",&T[i].left);

    T[T[i].left].parent = T[i].key;

    if(i == 0){
      T[i].parent = -1;
      continue;
    }

    for(j=0; j<k-1; j++){
      scanf("%d ",&T[i].right[j]);
      T[T[i].right[j]].parent = T[i].key;
    }

  }

  // output
  for(i=0; i<n; i++){
    d = calcDepth(&T[i]);
    printf("node %d: parent = %d, depth = %d, ",T[i].key, T[i].parent, d);

    if(T[i].parent == -1) printf("root, ");
    else if(T[i].left == NULL) printf ("leaf, ");
    else printf("internal node, ");

    if(k == 0) printf("[]\n");
    else{
      printf("[%d,",T[i].left);
      for(j=0; j<k-1; j++){
	if(j == k-1) printf("%d",T[i].right[j]);
	else printf("%d, ",T[i].right[j]);
      }
      printf("]\n");
    }

  }

  for(i=0; i<n; i++) free(T[i].right);
  free(T);

  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:26:18: error: assignment to 'int **' from incompatible pointer type 'int *' [-Wincompatible-pointer-types]
   26 |       T[i].right = (int *)malloc(sizeof(int));
      |                  ^
main.c:31:16: error: assignment to 'int **' from incompatible pointer type 'int *' [-Wincompatible-pointer-types]
   31 |     T[i].right = (int *)malloc(sizeof(int) * k-1);
      |                ^
main.c:35:6: error: array subscript is not an integer
   35 |     T[T[i].left].parent = T[i].key;
      |      ^
main.c:38:19: error: assignment to 'int *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
   38 |       T[i].parent = -1;
      |                   ^
main.c:44:8: error: array subscript is not an integer
   44 |       T[T[i].right[j]].parent = T[i].key;
      |        ^
main.c:51:9: error: implicit declaration of function 'calcDepth' [-Wimplicit-function-declaration]
   51 |     d = calcDepth(&T[i]);
      |         ^~~~~~~~~
main.c:54:20: warning: comparison between pointer and integer
   54 |     if(T[i].parent == -1) printf("root, ");
      |                    ^~
Language: C

#include <stdio.h>
#define MAX 100000
#define N -1

typedef struct Node{
  int poo,loo,roo;
}Node;

Node Ty[MAX];

int depth(int);
void p_degree(int);

int main(){

  int i,j,n,node,degree,children,left;

  scanf("%d",&n);

  for(i = 0; i < n; i++){
    Ty[i].poo = N;
    Ty[i].loo = N;
    Ty[i].roo = N;
  }

  for(i = 0; i < n; i++){
    scanf("%d%d",&node,&degree);
    for(j = 0; j < degree; j++){
      scanf("%d",&children);
      Ty[children].poo = node;
      if(j == 0) Ty[node].loo = children;
      else Ty[left].roo = children;
      left = children;
    }
  }

  for(i = 0; i < n; i++){
      printf("node %d: parent = %d, depth = %d, ",i,Ty[i].poo,depth(i));
    
    if(Ty[i].poo == NIL) printf("root, [");
    else if(Ty[i].loo == NIL) printf("leaf, [");
    else printf("internal node, [");
    
    p_degree(Ty[i].loo);
    printf("]\n");
  }

  return 0;
}

int depth(int node)
{
  int count = 0;
  
  while(Ty[node].poo != N){
    count++;
    node = Ty[node].poo;
  }
  return count;
}

void p_degree(int i)
{
  if(i != N){
    if(Ty[i].roo == N) printf("%d",i);
    else printf("%d, ",i);
    p_degree(Ty[i].roo);
  }
}
    

Compiler output:
main.c: In function 'main':
main.c:40:21: error: 'NIL' undeclared (first use in this function)
   40 |     if(Ty[i].poo == NIL) printf("root, [");
      |                     ^~~
main.c:40:21: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include<stdio.h>
#define A -1
#define N 100005
 struct Node{
   int p,l,r;
 };
 
   struct Node T[N];
 
int depth(int);
void ko(int);
int main(){
  int id,k,c,m,i,j,n;

  scanf("%d",&n);
  for(i=0; i<n; i++){
    T[i].p = A;
    T[i].l = A;
    T[i].r = A;
  }
 
  for(i=0; i<n; i++){
    scanf("%d%d",&id,&k);
    for(j=0; j<k; j++){
      scanf("%d",&c);
      T[c].p = id;
      if(j == 0) T[id].l = c;
      else T[m].r = c;
      m=c;
    }
  }
 
  for(i=0; i<n; i++){
    printf("node %d: parent = %d, depth = %d, ", i,T[i].p,depth(i));
    if(T[i].p == A) printf("root, [");
    else if(T[i].l==A) printf("leaf, [");
    else printf("internal node, [");
 
    ko(i);
  }
 
  return 0;
}
 
int depth(int x){
  int d=0;
  while(T[x].p != A){
    u = T[x].p;
    d++;
  }
  return d;
}
 
void ko(int x){
  int c;
  c = T[x].l;
  while(c != NIL){
    printf("%d",c);
    c = T[c].r;
    if(c != A){
      printf(", ");
    }
  }
  printf("]\n");
}

Compiler output:
main.c: In function 'depth':
main.c:48:5: error: 'u' undeclared (first use in this function)
   48 |     u = T[x].p;
      |     ^
main.c:48:5: note: each undeclared identifier is reported only once for each function it appears in
main.c: In function 'ko':
main.c:57:14: error: 'NIL' undeclared (first use in this function)
   57 |   while(c != NIL){
      |              ^~~
Language: C

#include<stdio.h>
#include<stdlib.h>

typedef struct TREE{
	int id;
	int depth;
	int k;
	struct TREE *parent;
	struct TREE **child;
}Tree;

Tree tree[100000];

void setDepth(Tree *nt, int depth){
	int i;
	if( nt == NULL ){ return; }
	nt->depth = depth;
	for( i = 0; i < nt->k; i++ ){
		setDepth(nt->child[i], depth+1);
	}
	return;
}

void print(Tree *p){
	int parent, nodetype, i;
	char *nodename[] = {"root", "internal node", "leaf"};
	if( p == NULL ){ return; }
	if( p->parent == NULL ){
		parent = -1;
	}else{
		parent = p->parent->id;
	}
	if( parent == -1 ){
		nodetype = 0;
	}else if( p->k > 0 ){
		nodetype = 1;
	}else{
		nodetype = 2;
	}
	printf("node %d: parent = %d, depth = %d, ", p->id, parent, p->depth);
	printf("%s, ", nodename[nodetype]);
	printf("[");
	if( p->k > 0 ){
		printf("%d", p->child[0]->id);
		for( i = 1; i < p->k; i++ ){
			printf(", %d", p->child[i]->id);
		}
	}
	printf("]\n");
	return;
}

int main(){
	int n, id, id2, i, j;
	scanf("%d", &n);
	Tree *root = NULL;
	for( i = 0; i < n; i++ ){
		tree[i].id = i;
		tree[i].parent = NULL;
		tree[i].child = NULL;
		tree[i].k = -1;
		tree[i].depth = -1;
	}
	for( i = 0; i < n; i++ ){
		scanf("%d", &id);
		scanf("%d", &tree[id].k);
		tree[id].child = (Tree**)malloc(sizeof(Tree*)*tree[id].k);
		for( j = 0; j < tree[id].k; j++ ){
			scanf("%d", &id2);
			tree[id].child[j] = &tree[id2];
			tree[id2]->parent = &tree[id];
		}
	}
	//???????±??????????
	for( i = 0; i < n; i++ ){
		if( tree[i].parent == NULL ){
			root = &tree[i];
			break;
		}
	}
	//??±???????±??????????
	setDepth(root, 0);
	//???????????????
	for( i = 0; i < n; i++ ){ print(&tree[i]); }
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:71:34: error: invalid type argument of '->' (have 'Tree' {aka 'struct TREE'})
   71 |                         tree[id2]->parent = &tree[id];
      |                                  ^~
Language: C

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int maxn = 100000 + 5;
struct node{
	int parent,leftchild,rightsibling,dep;
}tree[maxn];
int findDep(struct node t)
{
	if(t.dep!=-1)return t.dep;
	if(t.parent == -1)return t.dep = 0;
	return 	t.dep = 1 + findDep(tree[t.parent]);
}
int main()
{		
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;++i)tree[i].parent = tree[i].leftchild = tree[i].rightsibling = tree[i].dep = -1;
	
	int id,k,c;
	for(int i=0;i<n;++i){	
		scanf("%d %d",&id,&k);
		if(k){
			int lemo;
			scanf("%d",&lemo);
			tree[lemo].parent = id;
			tree[id].leftchild = lemo;
			
			for(int i=1;i<k;++i){
				scanf("%d",&c);
				tree[c].parent = id;
				tree[lemo].rightsibling = c;
				lemo = c;
			}
		}
	}	
	for(int i=0;i<n;++i)tree[i].dep = findDep(tree[i]);
	
	for(int i=0;i<n;++i){
		printf("node %d: parent = %d, depth = %d, %s, [",i,tree[i].parent,tree[i].dep,tree[i].parent==-1?("root"):(tree[i].leftchild==-1?("leaf"):("internal node")));
		int child = tree[i].leftchild;
		if(child!=-1){printf("%d",child);child = tree[child].rightsibling;}
		while(child!=-1){
			printf(", %d",child);
			child = tree[child].rightsibling;
		}
		printf("]\n");
	}
	return 0;
}

Compiler output:
main.c:1:10: fatal error: iostream: No such file or directory
    1 | #include <iostream>
      |          ^~~~~~~~~~
compilation terminated.
Language: C

#include<stdio.h>
#define NUM 100000

typedef struct Node{
  int parent,left,right;
    }Node;
  
Node T[NUM];
int n,D[NUM];

void print(int a){
  int i,b;

  printf("node %d: parent = %d, depth = %d, ", u, T[a].parent, D[a]);

  if(T[a].parent == -1)
    printf("root, [");

  else if(T[a].left == -1)
    printf("leaf, [");

  else
    printf("internal node, [");

  b = T[a].left;

  for(i = 0; b != -1; i++, b = T[b].right){
    if(i)
      printf(", ");

    printf("%d", b);
  }

  printf("]\n");
}

int depth(int a, int b){
  D[a] = b;
 
  if(T[a].right != -1)
    depth(T[a].right, b);

  if(T[a].left != -1)
    depth(T[a].left, b+1);
}

int main(){
  int a,b,c,left,right,i,j;

  scanf("%d", &n);

  for(i = 0; i < n; i++)
    T[i].parent = T[i].left = T[i].right = -1;
  
  for(i = 0; i < n; i++){
    scanf("%d%d", &a, &b);
    
    for(j = 0; j < b; j++){
      scanf("%d", &c);
      
      if(j == 0)
	T[a].left = c;
      
      else
	T[left].right = c;
      
      left = c;
	T[c].parent = a;
    }
  }
  
  for(i = 0; i < n; i++){
    if(T[i].parent == -1)
      right = i;
  }
  
  depth(right, 0);

  for(i = 0; i < n; i++)
    print(i);
  
  return 0;
}

Compiler output:
main.c: In function 'print':
main.c:14:48: error: 'u' undeclared (first use in this function)
   14 |   printf("node %d: parent = %d, depth = %d, ", u, T[a].parent, D[a]);
      |                                                ^
main.c:14:48: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include<stdio.h>
#define NIL -1
#define MAX 100000

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

struct Node T[MAX];
int n;

int depth(int a){
  
  int num=0,s=T[a].p;
  
  while(s!=NIL){
    num++;
    s=T[s].p;
  }
  return num;
}

int main(){

  int i,j,x,d,c,l;

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

  for(i=0;i<n;i++){
    scanf("%d %d",&x,&d);
    for(j=0;j<d;j++){
      scanf("%d", &c);
      if(j==0) T[x].l=c;
      else T[l].r =c;
      l=c;
      T[c].p=x;
    }
  }

  printf("node %d: parent = %d, depth = %d, ", a, T[a].p,depth(a));

  if(T[a].p==NIL) printf("root, ");
  else if(T[a].l!=NIL) printf("internal node, ");
  else printf("leaf, ");

  printf("["); 

  for(i=0, c=T[a].l; c!=NIL; i++, c=T[c].r){
    if(i==0) printf("%d", c);
    else printf(", %d", c);
  }
  printf("]\n");

  return 0;
}
  

Compiler output:
main.c: In function 'main':
main.c:42:48: error: 'a' undeclared (first use in this function)
   42 |   printf("node %d: parent = %d, depth = %d, ", a, T[a].p,depth(a));
      |                                                ^
main.c:42:48: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include<stdio.h>
#define NUM 100000

typedef struct Node{
  int parent,left,right;
}Node;

Node T[NUM];
int n,A[NUM],B[num];

void depth(int a, int b){
  if(a == -1)
    return 0;

  A[a] = b;
  depth(T[a].left, b+1);
  depth(T[a].right, b+1);
}

int height(int a){
  int h1=0,h2=0;

  if(T[a].left != -1)
    h1 = height(T[a].left)+1;

  if(T[a].right != -1)
    h2 = height(T[a].right)+1;

  if(h1 > h2)
    return B[a] = h1;

  else
    return B[a] = h2;
}

int sibling(int a){
  if(T[a].parent == -1)
    return -1;

  if(T[T[a].parent].left != a && T[T[a].parent].left != -1)
    return T[T[a].parent].left;

  if(T[T[a].parent],right != a && T[T[a].parent].right != -1)
    return T[T[a].parent].right;

  return -1;
}

void print(int a){
  int d = 0;

  printf("node %d: parent = %d, sibling = %d, ", a, T[a].parent, sibling(a));

  if(T[a].left != -1)
    d++; 

  if(T[a].right != -1)
    d++;

  printf("degree = %d, depth = %d, height = %d, ", d, A[a], B[a]);


  if(T[a].parent == -1)
    printf("root\n");

  else if(T[a].left == -1 && T[a].right == -1)
    printf("leaf\n");

  else
    printf("internal node\n");
}

int main(){
  int a,l,ri,ro,i;

  scanf("%d", &n);

  for(i = 0; i < n; i++)
    T[i].parent = -1;

  for(i = 0;i < n; i++){
    scanf("%d%d%d", &a, &l, &ri);

    T[a].left = l;
    T[a].right = ri;

    if(l != -1)
      T[l].parent = a;

    if(ri != -1)
      T[ri].parent = a;
  }

  for(i = 0; i < n; i++){
    if(T[i].parent == -1)
      ro = i;
  }

  depth(ro, 0);
  hright(ro);

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

  return 0;
}

Compiler output:
main.c:9:16: error: 'num' undeclared here (not in a function)
    9 | int n,A[NUM],B[num];
      |                ^~~
main.c: In function 'depth':
main.c:13:12: error: 'return' with a value, in function returning void [-Wreturn-mismatch]
   13 |     return 0;
      |            ^
main.c:11:6: note: declared here
   11 | void depth(int a, int b){
      |      ^~~~~
main.c: In function 'sibling':
main.c:43:21: error: 'right' undeclared (first use in this function); did you mean 'height'?
   43 |   if(T[T[a].parent],right != a && T[T[a].parent].right != -1)
      |                     ^~~~~
      |                     height
main.c:43:21: note: each undeclared identifier is reported only once for each function it appears in
main.c: In function 'main':
main.c:100:3: error: implicit declaration of function 'hright'; did you mean 'height'? [-Wimplicit-function-declaration]
  100 |   hright(ro);
      |   ^~~~~~
      |   height
Language: C

#include<stdio.h>
#define NIL -1
#define MAX 100000

typedef struct{
  int p,l,r;
}Node;

struct Node T[MAX];
int n;

int depth(int a){
  
  int num=0,s=T[a].p;
  
  while(s!=NIL){
    num++;
    s=T[s].p;
  }
  return num;
}

int main(){

  int i,j,x,d,c,l;

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

  for(i=0;i<n;i++){
    scanf("%d %d",&x,&d);
    for(j=0;j<d;j++){
      scanf("%d", &c);
      if(j==0) T[x].l=c;
      else T[l].r =c;
      l=c;
      T[c].p=x;
    }
  }
  for(i=0;i<n;i++){
  printf("node %d: parent = %d, depth = %d, ", i, T[i].p,depth(i));

  if(T[i].p==NIL) printf("root, ");
  else if(T[i].l!=NIL) printf("internal node, ");
  else printf("leaf, ");

  printf("["); 

  for(j=0, c=T[i].l; c!=NIL; j++, c=T[c].r){
    if(j==0) printf("%d", c);
    else printf(", %d", c);
  }
  printf("]\n");
  }
  return 0;
}
  

Compiler output:
main.c:9:13: error: array type has incomplete element type 'struct Node'
    9 | struct Node T[MAX];
      |             ^
Language: C

#include<stdio.h>
#include<stdlib.h>
typedef struct{
  int parent;
  int letf;
  int right;
}Node;

int main(){
  int n,k,id,h,r,depth,p,i,j;
  Node *T;

  scanf("%d", &n);

  T=malloc(sizeof(Node)*n);

  for(i=0;i<n;i++){
    T[i].parent=-1;
    T[i].left=-1;
    T[i].right=-1;
  }

  for(i=0;i<n;i++){
    scanf("%d %d", &id, &k);
    for(j=0;j<k;j++){
      scanf("%d",&h);
      T[h].parent=id;

      if(j==0) T[id].left=h;
      else if(j>0) T[r].right = h;
      r=h;
    }
  }

  for(j=0;j<n;j++){
    dep=0;
    p=T[j].parent;

    while(p!=-1){
      p=T[p].parent;
      dep++;
    }

    if(dep==0){
      printf("node %d: parent = -1, depth = 0, root, [", j);
    }
    
    else if(T[j].left == -1){
      printf("node %d: parent = %d, depth = %d, leaf, [", j, T[j].parent, dep);
    }
    else{
      printf("node %d: parent = %d, depth = %d, internal node, [", j, T[j].parent, dep);
    }
 
    p = T[j].left;
    if(p != -1) printf("%d", p);
 
    while(p != -1){
      p = T[p].right;
      if(p != -1) printf(", %d", p);
    }
    printf("]\n");
  }
 
  return 0;

Compiler output:
main.c: In function 'main':
main.c:19:10: error: 'Node' has no member named 'left'; did you mean 'letf'?
   19 |     T[i].left=-1;
      |          ^~~~
      |          letf
main.c:29:22: error: 'Node' has no member named 'left'; did you mean 'letf'?
   29 |       if(j==0) T[id].left=h;
      |                      ^~~~
      |                      letf
main.c:36:5: error: 'dep' undeclared (first use in this function)
   36 |     dep=0;
      |     ^~~
main.c:36:5: note: each undeclared identifier is reported only once for each function it appears in
main.c:48:18: error: 'Node' has no member named 'left'; did you mean 'letf'?
   48 |     else if(T[j].left == -1){
      |                  ^~~~
      |                  letf
main.c:55:14: error: 'Node' has no member named 'left'; did you mean 'letf'?
   55 |     p = T[j].left;
      |              ^~~~
      |              letf
main.c:65:3: error: expected declaration or statement at end of input
   65 |   return 0;
      |   ^~~~~~
Language: C

#include <stdio.h>
#include <stdlib.h>

 typedef struct{
   int parent;
   int left;
   int right;
 }Node;

int main(){
  int n, id, k, depth, a, i, j, b, c;
  Node *T;

  scanf("%d", &n);

  T = malloc(sizeof(Node)*n);

  for(i = 0; i < n; i++){
    T[i].parent = -1;
    T[i].left = -1;
    T[i].right = -1;
  }

  for(i = 0; i < n; i++){
    scanf("%d%d", &id, &k);

    for(j = 0; j < k; j++){
      scanf("%d", &a);
      T[a].parent = id;

      if(j == 0)
	T[id].left = a;
      else if(j > 0)
	T[b].right = a;

      b = a;
    }
  }

  for(i = 0; i < n; j++){
    depth = 0;
    c = T[i].parent;

    while(c != -1){
      c = T[c].parent;
      depth++;
    }
    if(i ==0)
      printf("node %d: parent = %d, depth = %d, root, [", i, i-1, i);
    else if(T[i].left == -1)
      printf("node %d: parent = %d, depth = %d, leaf, [", i, T[i].parent, depth);
    else
      printf("node %d: parent = %d, depth = %d, internal node, [", i, T[i].parent, depth);

    c = T[i].left;
    if(c != -1)
      printf("%d", c);

    while(1){
      c = T[c].right;
      if(c != -1)
	ptintf(", %d", c);
      if(c == -1) break;
    }
    printf("]\n");
  }
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:62:9: error: implicit declaration of function 'ptintf'; did you mean 'printf'? [-Wimplicit-function-declaration]
   62 |         ptintf(", %d", c);
      |         ^~~~~~
      |         printf
Language: C

#include <stdio.h>
#define MAX 100000
#define NIL -1

struct Node{
  int p;
  int l;
  int r;
};
struct Node T[MAX];


 /*??±????????°??????*/
int getDepth(int x){

  int dep;

  while(T[x].p != NIL){
    x = T[x].p;
    dep++;
  }
  return dep;
}

void Print(x){

  int a;
 
  if(T[x].p == NIL) printf("node %d: parent = %d, depth = %d, root, ",x,T[x].p,T[x]);
  else if(T[x].l == NIL) printf("node %d: parent = %d, depth = %d, leaf, ",x, T[x].p,T[x]);
  else printf("node %d: parent = %d, depth = %d, internal node, ",x,T[x].p,T[x]);   
 
  printf("[");
  a = x;
 
  if(T[a].l != NIL){
    printf("%d", T[x].l);
    if(T[T[x].l].r == NIL) printf("]\n");
    else printf(",");
    a = T[a].l;

    while(T[a].r != NIL){
      printf(" %d",T[a].r);
      if(T[T[a].r].r == NIL) printf("]\n");
      else printf(",");
      a = T[a].r;
    }
  }
   
  else printf("]\n");
}


int main(void){

  int???n,i,j,a,b,c,r;

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

  for(i = 0; i < n; i++){
    scanf("%d %d",&a,&b);
    for(j = 0; j < b; j++){
      scanf("%d",&c);
      T[c].p = a;
      if(j == 0) T[a].l = c;
      else if (j >= 1) T[r].r = c;
      r = c;
    }
  }

  for(i = 0; i <n; i++) getDepth(i);
  for(i = 0; i <n; i++) Print(i);

  return 0;
}

Compiler output:
main.c: In function 'Print':
main.c:25:6: error: type of 'x' defaults to 'int' [-Wimplicit-int]
   25 | void Print(x){
      |      ^~~~~
main.c: In function 'main':
main.c:56:6: error: expected identifier or '(' before '?' token
   56 |   int???n,i,j,a,b,c,r;
      |      ^
main.c:58:15: error: 'n' undeclared (first use in this function)
   58 |   scanf("%d",&n);
      |               ^
main.c:58:15: note: each undeclared identifier is reported only once for each function it appears in
main.c:59:7: error: 'i' undeclared (first use in this function)
   59 |   for(i = 0; i < n; i++){
      |       ^
main.c:66:20: error: 'a' undeclared (first use in this function)
   66 |     scanf("%d %d",&a,&b);
      |                    ^
main.c:66:23: error: 'b' undeclared (first use in this function)
   66 |     scanf("%d %d",&a,&b);
      |                       ^
main.c:67:9: error: 'j' undeclared (first use in this function)
   67 |     for(j = 0; j < b; j++){
      |         ^
main.c:68:19: error: 'c' undeclared (first use in this function)
   68 |       scanf("%d",&c);
      |                   ^
main.c:71:26: error: 'r' undeclared (first use in this function)
   71 |       else if (j >= 1) T[r].r = c;
      |                          ^
Language: C

#include<stdio.h>
#define MAX 100000

typedef struct{
int p;
int l,r;
}Tree;

Tree A[MAX];

int Dep(int);

main(){
int i,j,n;
int num,deg,c,k=0;

scanf("%d",&n);
for(i=0;i<n;i++){
A[i].p=-1;
A[i].l=-1;
A[i].r=-1;
}
for(i=0;i<n;i++){
scanf("%d%d",&num,&deg);
for(j=0;j<deg;j++){
scanf("%d",&c);
if(j==0)A[num].l=c;
else A[k].r=c;
k=c;
A[c].p=num;
}
}
for(i=0;i<n:i++){
printf("node %d; parent-%d,depth=%d+,i,A[i].p,dep(i));
if(Dep(i)==0){
printf(", root, [");
}
else if(A[i].l==-1){
printf(", leaf, [");
else{
printf(", internal node, [");
}
j=A[i].l;

while(j!=-1){
printf("%d",j);
j=A[j].r;
if(j!--1){
printf(", ");
}
}
printf("]\n");
}
return 0;
}

int Dep(int num){
int dep=0;
while(A[num].p!=-1){
num=A[num].p;
dep++;
}
return dep;
}

Compiler output:
main.c:13:1: error: return type defaults to 'int' [-Wimplicit-int]
   13 | main(){
      | ^~~~
main.c: In function 'main':
main.c:33:12: error: expected ';' before ':' token
   33 | for(i=0;i<n:i++){
      |            ^
      |            ;
main.c:34:8: warning: missing terminating " character
   34 | printf("node %d; parent-%d,depth=%d+,i,A[i].p,dep(i));
      |        ^
main.c:34:8: error: missing terminating " character
   34 | printf("node %d; parent-%d,depth=%d+,i,A[i].p,dep(i));
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.c:35:1: error: expected expression before 'if'
   35 | if(Dep(i)==0){
      | ^~
main.c:54:10: error: expected ';' before '}' token
   54 | return 0;
      |          ^
      |          ;
   55 | }
      | ~         
main.c:64:1: error: expected declaration or statement at end of input
   64 | }
      | ^
Language: C

#include<stdio.h>
#define MAX 100000

typedef struct{
int p;
int l,r;
}Tree;

Tree A[MAX];

int Dep(int);

main(){
int i,j,n;
int num,deg,c,k=0;

scanf("%d",&n);
for(i=0;i<n;i++){
A[i].p=-1;
A[i].l=-1;
A[i].r=-1;
}
for(i=0;i<n;i++){
scanf("%d%d",&num,&deg);
for(j=0;j<deg;j++){
scanf("%d",&c);
if(j==0)A[num].l=c;
else A[k].r=c;
k=c;
A[c].p=num;
}
}
for(i=0;i<n:i++){
printf("node %d; parent-%d,depth=%d+,i,A[i].p,Dep(i));
if(Dep(i)==0){
printf(", root, [");
}
else if(A[i].l==-1){
printf(", leaf, [");
else{
printf(", internal node, [");
}
j=A[i].l;

while(j!=-1){
printf("%d",j);
j=A[j].r;
if(j!--1){
printf(", ");
}
}
printf("]\n");
}
return 0;
}

int Dep(int num){
int dep=0;
while(A[num].p!=-1){
num=A[num].p;
dep++;
}
return dep;
}

Compiler output:
main.c:13:1: error: return type defaults to 'int' [-Wimplicit-int]
   13 | main(){
      | ^~~~
main.c: In function 'main':
main.c:33:12: error: expected ';' before ':' token
   33 | for(i=0;i<n:i++){
      |            ^
      |            ;
main.c:34:8: warning: missing terminating " character
   34 | printf("node %d; parent-%d,depth=%d+,i,A[i].p,Dep(i));
      |        ^
main.c:34:8: error: missing terminating " character
   34 | printf("node %d; parent-%d,depth=%d+,i,A[i].p,Dep(i));
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.c:35:1: error: expected expression before 'if'
   35 | if(Dep(i)==0){
      | ^~
main.c:54:10: error: expected ';' before '}' token
   54 | return 0;
      |          ^
      |          ;
   55 | }
      | ~         
main.c:64:1: error: expected declaration or statement at end of input
   64 | }
      | ^