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

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

void print(int);


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

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

int main(){
  int i,j;
  int a,l,r;
  int root;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].parent = NIL;
  }
  for(i=0;i<n;i++){
    scanf("%d %d %d",&a,&l,&r);
    T[a].left = l;
    T[a].right = r;
    if( l != NIL) T[l].parent = a;
    if( r != NIL) T[r].parent = a;
  }
  for(i = 0; i <n; i++){
    if(T[i].parent == NIL) root = i;
  }
  setDepth(root,0);
  setHeight(root);

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

int setDepth(int u,int d){
  if(u == NIL) return NIL;
  D[u] = d;
  setDepth(T[u].left,d + 1);
  setDepth(T[u].right, d + 1);
}

int setHeight(int u){
  int h1=0;
  int h2=0;
  if(T[u].left != NIL) h1 = setHeight(T[u].left) +1;
  if(T[u].right != NIL) h2 = setHeight(T[u].right) +1;
  if(h1>h2){
    H[u] = h1;
  }
  else{
    H[u] = h2;
  }
    return H[u];
}

int getSibling(int u){
  if(T[u].parent == NIL) return NIL;
  if(T[T[u].parent].right != NIL && T[T[u].parent].right !=NIL)
    return T[T[u].parent].right;
  if(T[T[u].parent].left != NIL &&T[T[u].parent].left !=NIL )
    return  T[T[u].parent].left;
  return NIL;
}

void print(int u){
  int i,c;
  int deg=0;
  printf("node %d: parent = %d, depth = %d, ",u,T[u].parent,D[u]);
  if(T[u].right != NIL) deg++;
  if(T[u].left != NIL) deg++;
  printf("sibling =  %d, degree = %d, ",getSibling(u),deg);
  printf("depth = %d, Height = %d, ",D[u],H[u]);
  
  if(T[u].parent==NIL) printf("root");
  else if(T[u].left == NIL) printf("leaf");
  else printf("internal node");
  printf("\n");
}




Compiler output:
Main.java:1: error: illegal character: '#'
#include <stdio.h>
^
Main.java:1: error: class, interface, enum, or record expected
#include <stdio.h>
         ^
Main.java:2: error: illegal character: '#'
#define NIL -1
^
Main.java:3: error: illegal character: '#'
#define MAX 10000
^
Main.java:8: error: class, interface, enum, or record expected
typedef struct{
^
Main.java:10: error: class, interface, enum, or record expected
}node;
^
Main.java:12: error: class, interface, enum, or record expected
node T[MAX];
^
Main.java:13: error: class, interface, enum, or record expected
int n,D[MAX];
^
Main.java:14: error: class, interface, enum, or record expected
int H[MAX];
^
Main.java:16: error: unnamed classes are a preview feature and are disabled by default.
int main(){
^
  (use --enable-preview to enable unnamed classes)
Main.java:20: error: illegal start of expression
  scanf("%d",&n);
             ^
Main.java:25: error: illegal start of expression
    scanf("%d %d %d",&a,&l,&r);
                     ^
Main.java:25: error: illegal start of expression
    scanf("%d %d %d",&a,&l,&r);
                        ^
Main.java:25: error: illegal start of expression
    scanf("%d %d %d",&a,&l,&r);
                           ^
14 errors
Language: Java

package binarytree;
import java.util.*;
import java.io.*;
public class Main {
	
	static final int NONUM=-1;
	public static void main(String[] args)throws IOException{
		final Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		NODE[] n = new NODE[a];
	
		for(int i=0;i<n.length;i++){
			int id=sc.nextInt();
			n[id]=new NODE();
			n[id].id = id;
			n[id].l = sc.nextInt();
			n[id].r = sc.nextInt();
			n[id].p = -1;
			n[id].s = -1;
			n[id].d = 0;
			n[id].t = "leaf";
			if(n[id].l != -1){
				n[id].d++;
				n[id].t = "internal node";
			}
			if(n[id].r != -1){
				n[id].d++;
				n[id].t = "internal node";
			}
		}
	     for(int i=0; i<a; i++){
	    	 if(n[i].l != -1){
	                n[n[i].l].p = n[i].id;
	            }
	            if(n[i].r != -1){
	                n[n[i].r].p = n[i].id;
	            }
	            if(n[i].l != -1 && n[i].r != -1){
	                n[n[i].l].s = n[i].r;
	                n[n[i].r].s = n[i].l;
	            }
	     }
		
	        for(int i=0; i<a; i++){
	            if(n[i].p == -1){
	                n[i].t = "root";
	                if(n[i].l != -1){
	                    getdepth(n, n[i].l, 1);
	                }
	                if(n[i].r != -1){
	                    getdepth(n, n[i].r, 1);
	                }
	            }
	            if(n[i].d == 0){
	                if(n[i].p != -1){
	                    getheight(n, n[i].p, 1);
	                }
	            }
	        }
		
		for(int i=0;i<a;i++){
			System.out.println("node "+n[i].id+": parent = "+n[i].p+", sibling = "+n[i].s+", degree = "+n[i].d+", depth = "+n[i].dep+", height = "+n[i].h+ ", "+n[i].t);
		}
	}
	
	static void getdepth(NODE[] n,int i,int d){
	     n[i].dep = d;
	        d++;
	        if(n[i].l != -1){
	            getdepth(n, n[i].l, d);
	        }
	        if(n[i].r != -1){
	            getdepth(n, n[i].r, d);
	        }
	        
	}	
	
	static void getheight(NODE[] n,int i, int h){
        if(h < n[i].h) h = n[i].h;
        else           n[i].h = h;
        h++;
        if(n[i].p != -1){
            getheight(n, n[i].p, h);
        }
	}
}
	
class NODE{
	int id;
	int r;
	int l;
	int p;
	int d;
	int dep;
	int h;
	int s;
	String t; 

Compiler output:
Main.java:97: error: reached end of file while parsing
	String t; 
	         ^
1 error
Language: C

#include <stdio.h>
#include <string.h>

struct node{
    int parent,left,right;
}T[30];

int H[30],D[30];

int setHeight(int u){
    int h1 = 0,h2 = 0;
    if(T[u].left != -1)
        h1 = setHeight(T[u].left)+1;
    if(T[u].right != -1)
        h2 = setHeight(T[u].right)+1;
    return H[u] = h1>h2?h1:h2;
}

void setDepth(int u,int d){
    D[u] = d;
    if(T[u].left != -1) setDepth(T[u].left,d+1);
    if(T[u].right ! = -1) setDepth(T[u].right,d+1);
}

void print(int u){
    int deg = 0;
    printf("node %d: parent = %d, ",u,T[u].parent);
    printf("sibling = ");
    if(T[u].parent == -1) printf("-1, "); 
    else if(T[T[u].parent].left != -1 && T[T[u].parent].left != u)
        printf("%d, ",T[T[u].parent].left);
    else if(T[T[u].parent].right != -1 && T[T[u].parent].right != u)
        printf("%d, ",T[T[u].parent].right);
    else
        printf("-1, ");
    if(T[u].left!=-1) deg++;
    if(T[u].right!=-1) deg++;
    printf("degree = %d, ",deg);
    printf("depth = %d, ",D[u]);
    printf("height = %d, ",H[u]);
    if(T[u].parent == -1) printf("root\n");
    else if(T[u].left == -1 && T[u].right == -1)printf("leaf\n");
    else printf("internal node\n");
}

int main(){
    int n,v,l,r;
    int root = 0;
    memset(T,-1,sizeof(T));
    scanf("%d",&n);
    for(int i = 0 ; i < n ; i++){
        scanf("%d%d%d",&v,&l,&r);
        if(l != -1){ T[v].left = l,T[l].parent = v;}
        if(r != -1){ T[v].right =r,T[r].parent = v;}
    }
    for(int i = 0; i < n ; i++)
        if(T[i].parent == -1){
            root = i;
            break;
        }
    setHeight(root);
    setDepth(root,0);
    for(int i = 0 ; i < n ; i++)
        print(i);
    return 0;
}


Compiler output:
main.c: In function 'setDepth':
main.c:22:18: error: expected ')' before '!' token
   22 |     if(T[u].right ! = -1) setDepth(T[u].right,d+1);
      |       ~          ^~
      |                  )
Language: C

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

int parent[MAX], left[MAX], right[MAX];
int n, D[MAX], H[MAX];

int getDepth(int u){
  int d = 0;
  while(parent[u] != NIL){
    u = parent[u];
    d++;
  }
  return d;
}
void setDepth(int u, int p){
  D[u] = p;
  if(right[u] != NIL){
    setDepth(right[u], p+1 );
  }
  if(left[u] != NIL){
    setDepth(left[u], p+1 );
  }
}

void seTHeight(int u){
  int h1 = 0;
  int h2 = 0;
  if( right[u] != NIL ){
    h1 = seTHeigh(H, right[u]) + 1;
  }
  if( left[u] != NIL ){
    h2 = seTHeigh(H,left[u]) + 1;
  }
}

int seTSibling(int u){
  if(parent[u] == NIL ) return NIL;
  if(left[parent[u]] != u && left[parent[u]] != NIL ) return left[parent[u]];
  if(right[parent[u]] != u && right[parent[u]] != NIL) return right[parent[u]];
  return NIL;
}

void printChildren(int u){

  int i, c;
  int deg = 0;

  printf("node %d: ", u);
  printf("parent = %d, ", parent[u]);
  printf("sibling = %d, ", seTSiblig(u));
  if(left[u] != NIL ) deg++;
  if(right[u] != NIL ) deg++;
  printf("degree = %d, ", deg);
  printf("depth = %d, ", D[u]);
  printf("height = %d, ", H[u]);

  if(parent[u] == NIL) printf("root\n");
  else if(left[u] == NIL && right[u] == NIL ) printf("leaf\n");
  else printf("internal node, ");
}

int main(){
  int i, d, v, l, r;
  scanf("%d", &n);
  for(i = 0 ; i < n ; i++)  parent[i] = left[i] = right[i] = NIL;

  for( i = 0 ; i < n ; i++){
    scanf("%d", &v);
    scanf("%d", &l);
    scanf("%d", &d);
    left[v] = l;
    right[v] = d;
    if(l != NIL ) parent[l] = v;
    if(d != NIL ) parent[d] = v;
  }
  for( i = 0 ; i < n ; i++){
    if( parent[i] == NIL ) r = i;
  }

  setDepth(r, 0);
  seTHeight(r);

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

  return 0;
}



Compiler output:
main.c: In function 'seTHeight':
main.c:30:10: error: implicit declaration of function 'seTHeigh'; did you mean 'seTHeight'? [-Wimplicit-function-declaration]
   30 |     h1 = seTHeigh(H, right[u]) + 1;
      |          ^~~~~~~~
      |          seTHeight
main.c: In function 'printChildren':
main.c:51:28: error: implicit declaration of function 'seTSiblig'; did you mean 'seTSibling'? [-Wimplicit-function-declaration]
   51 |   printf("sibling = %d, ", seTSiblig(u));
      |                            ^~~~~~~~~
      |                            seTSibling
Language: C

#include<stdio.h>
#include<stdlib.h>
typedef struct Node{
  int id;
  int k;
  struct Node *p;
  struct Node *left;
  struct Node *right;
}node;

int getdepth(node);
char* gettype(node);
void drowchildren(node);

int main(){

  int i,j;
  int a,n;
  int id;

  //input
  scanf("%d",&n);
  node tree[n];
  for(i=0;i<n;i++){
    tree[i].p=NULL;
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&id);
    tree[id].id=id; 
    tree[id].c=(node*)malloc(2*sizeof(node));
    for(j=0;j<t;j++){
      scanf("%d",&tree[id].c[j].id);
      tree[tree[id].c[j].id].p=&tree[id];
    }
  }
  //output
  for(i=0;i<n;i++){
    printf("node %d: ",i);
    if(tree[i].p==NULL) printf("parent = -1, ");
    else printf("parent = %d, ",tree[i].p->id);
    printf("depth = %d, ",getdepth(tree[i]));
    printf("%s, ",gettype(tree[i]));
    drowchildren(tree[i]);
  }
  
  //free 
  for(i=0;i<n;i++){
    free(tree[i].c);
  }
  return 0;
}

int getdepth(node tree){

  int count=0;
  node *q;
  
  if(tree.p==NULL) return 0;
  q=&tree;
  while(q->p!=NULL){
    q=q->p;
    count++;
  }
  return count;
}
char* gettype(node tree){
  if(tree.p==NULL) return "root";
  if(tree.k>=1) return "internal node";
  else return "leaf";
}
void drowchildren(node tree){

  int i;
 
  if(tree.k==0){
    printf("[]\n");
  }
  else{
    printf("[");
    for(i=0;i<tree.k;i++){
      if(i==tree.k-1) printf("%d]\n",tree.c[i].id);
      else printf("%d, ",tree.c[i].id);
    }
  }
}



Compiler output:
main.c: In function 'main':
main.c:30:13: error: 'node' {aka 'struct Node'} has no member named 'c'
   30 |     tree[id].c=(node*)malloc(2*sizeof(node));
      |             ^
main.c:31:15: error: 't' undeclared (first use in this function)
   31 |     for(j=0;j<t;j++){
      |               ^
main.c:31:15: note: each undeclared identifier is reported only once for each function it appears in
main.c:32:27: error: 'node' {aka 'struct Node'} has no member named 'c'
   32 |       scanf("%d",&tree[id].c[j].id);
      |                           ^
main.c:33:20: error: 'node' {aka 'struct Node'} has no member named 'c'
   33 |       tree[tree[id].c[j].id].p=&tree[id];
      |                    ^
main.c:48:17: error: 'node' {aka 'struct Node'} has no member named 'c'
   48 |     free(tree[i].c);
      |                 ^
main.c: In function 'drowchildren':
main.c:81:42: error: 'node' {aka 'struct Node'} has no member named 'c'
   81 |       if(i==tree.k-1) printf("%d]\n",tree.c[i].id);
      |                                          ^
main.c:82:30: error: 'node' {aka 'struct Node'} has no member named 'c'
   82 |       else printf("%d, ",tree.c[i].id);
      |                              ^
Language: C

#include"iostream"
#include"stdio.h"
#include"vector"
#include"stdlib.h"

using namespace std;

class branch
{
private:
public:
  int id;
  int p;
  int depth;
  vector<int> c;
  branch()
  {
  }
  void print()
  {
    cout<<"node "<<id<<": parent = "<<p<<", depth = "<<depth<<", ";
    if(p==-1)
      {
        cout<<"root, [";
      }
    else if(!c.size())
      {
        cout<<"leaf, [";
      }
    else
      {
        cout<<"internal node, [";
      }
    if(0<c.size())
      {
        cout<<c[0];
        for(int i=1;i<c.size();i++)
          {
            cout<<", "<<c[i];
          }
      }
    cout<<"]"<<endl;
  }
};
vector<branch> tree;
int countDepth(int id)
{
  if(tree[id].p!=-1)return 1+countDepth(tree[id].p);
  return 0;
}

int main()
{
  branch buf;
  int n;
  cin>>n;
  buf.p=-1;
  for(int i=0;i<n;i++)
    {
      tree.push_back(buf);
    }
  for(int i=0;i<n;i++)
    {
      int id;
      int k;
      cin>>id;
      tree[id].id=id;
      cin>>k;
      for(int j=0;j<k;j++)
        {
          int c;
          cin>>c;
          tree[id].c.push_back(c);
          tree[c].p=id;
        }
    }
  for(int i=0;i<tree.size();i++)
    {
      tree[i].depth=countDepth(tree[i].id);
      tree[i].print();
    }
  return 0;
}



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

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

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

struct Node T[MAX];

int n;
int Depth[MAX], Height[MAX];

int GetDepth(int u){
  int d = 0;
  while(1){
    u = T[u].p;
    if ( u == NIL ) break;
    d++;
  }
  return d;
}

int GetS(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("parent = %d, ", T[u].p);
  printf("sibling = %d, ", GetS(u));

  int deg = 0;
  
  if ( T[u].l != NIL ) deg++;
  if ( T[u].r != NIL ) deg++;
  
  printf("degree = %d, ", deg);
  printf("depth = %d, ", Depth[u]);
  printf("height = %d, ", Height[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");
  }
}

int main(){
  int i, v, l, r;
  
  scanf("%d", &n);

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

  for ( 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 ( i = 0; i < n; i++ ){
    Depth[i] = GetDepth(i);
    Height[i] = 0;
  }

  for ( i = 0; i < n; i++ ){
    if ( T[i].l == NIL && T[i].r == NIL ) {
      Height[i] = 0;
      p = T[i].p;
      c = 1;

      while(1){
	if ( p == NIL ) break;
	if ( Height[p] < c ) Height[p] = c;
	c++;
	p = T[p].p;
      }
    }
  }

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



Compiler output:
main.c: In function 'main':
main.c:82:7: error: 'p' undeclared (first use in this function)
   82 |       p = T[i].p;
      |       ^
main.c:82:7: note: each undeclared identifier is reported only once for each function it appears in
main.c:83:7: error: 'c' undeclared (first use in this function)
   83 |       c = 1;
      |       ^
Language: C

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

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

struct Node T[MAX];

int n;
int Depth[MAX], Height[MAX];

int GetDepth(int u){
  int d = 0;
  while(1){
    u = T[u].p;
    if ( u == NIL ) break;
    d++;
  }
  return d;
}

int GetS(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("parent = %d, ", T[u].p);
  printf("sibling = %d, ", GetS(u));

  int deg = 0;
  
  if ( T[u].l != NIL ) deg++;
  if ( T[u].r != NIL ) deg++;
  
  printf("degree = %d, ", deg);
  printf("depth = %d, ", Depth[u]);
  printf("height = %d, ", Height[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");
  }
}

int main(){
  int i, v, l, r;
  
  scanf("%d", &n);

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

  for ( 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 ( i = 0; i < n; i++ ){
    Depth[i] = GetDepth(i);
    Height[i] = 0;
  }

  for ( i = 0; i < n; i++ ){
    if ( T[i].l == NIL && T[i].r == NIL ) {
      Height[i] = 0;
      p = (int)T[i].p;
      c = 1;

      while(1){
	if ( p == NIL ) break;
	if ( Height[p] < c ) Height[p] = c;
	c++;
	p = T[p].p;
      }
    }
  }

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



Compiler output:
main.c: In function 'main':
main.c:82:7: error: 'p' undeclared (first use in this function)
   82 |       p = (int)T[i].p;
      |       ^
main.c:82:7: note: each undeclared identifier is reported only once for each function it appears in
main.c:83:7: error: 'c' undeclared (first use in this function)
   83 |       c = 1;
      |       ^
Language: C

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

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

struct Node T[MAX];

int n;
int Depth[MAX], Height[MAX];

int GetDepth(int u){
  int d = 0;
  while(1){
    u = T[u].p;
    if ( u == NIL ) break;
    d++;
  }
  return d;
}

int GetS(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("parent = %d, ", T[u].p);
  printf("sibling = %d, ", GetS(u));

  int deg = 0;
  
  if ( T[u].l != NIL ) deg++;
  if ( T[u].r != NIL ) deg++;
  
  printf("degree = %d, ", deg);
  printf("depth = %d, ", Depth[u]);
  printf("height = %d, ", Height[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");
  }
}

int main(){
  int i, v, l, r;
  
  scanf("%d", &n);

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

  for ( 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 ( i = 0; i < n; i++ ){
    Depth[i] = GetDepth(i);
    Height[i] = 0;
  }

  for ( i = 0; i < n; i++ ){
    if ( T[i].l == NIL && T[i].r == NIL ) {
      Height[i] = 0;
      p = T[i].p(int);
      c = 1;

      while(1){
	if ( p == NIL ) break;
	if ( Height[p] < c ) Height[p] = c;
	c++;
	p = T[p].p;
      }
    }
  }

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



Compiler output:
main.c: In function 'main':
main.c:82:7: error: 'p' undeclared (first use in this function)
   82 |       p = T[i].p(int);
      |       ^
main.c:82:7: note: each undeclared identifier is reported only once for each function it appears in
main.c:82:18: error: expected expression before 'int'
   82 |       p = T[i].p(int);
      |                  ^~~
main.c:82:11: error: called object is not a function or function pointer
   82 |       p = T[i].p(int);
      |           ^
main.c:83:7: error: 'c' undeclared (first use in this function)
   83 |       c = 1;
      |       ^
Language: C

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

int parent[MAX],left[MAX],right[MAX];
int n,D[MAX],H[MAX];

void setDepth(int u,int d){
  if(u== NIL) return;
  D[u]=d;
  setDepth(left[u],d+1);
  setDepth(right[u],d+1);
}

int setHeight(int u){
  int h1=0,h2=0;
  if(left[u]!=NIL){
  h1 = setHeight(left[u])+1;}
  if(right[u]!=NIL){
  h2 = setHeight(right[u])+1;}
  return H[u]=(h1>h2 ? h1 : h2);
}


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 MAX 1000005
#define NIL -1

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

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

int getSibling(int u){
  if(T[u].p == NIL){
    return -1;
}
  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 -1;
}

void print(int u){
  int sub;
  int dgree=0;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("sibling = %d, ",sub = getSibling(u));
  if(T[u].l! = -1){
    dgree++;
      }
  if(T[u].r! = -1){
    dgree++;
  }
  printf("degree = %d, ",dgree);
  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");
  }
}



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

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

int main(){
  int i, v, l, r, root = 0;
  scanf("%d",&n);

  for(i=0 ; i<n ; i++){
    T[i].p = NIL;
  }
  for(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(i=0 ; i<n ; i++ ){
    if(T[i].p == NIL){
      root = i;
    }
  }
  setDepth(root, 0);
  setHeight(root);

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




Compiler output:
main.c: In function 'print':
main.c:33:12: error: expected ')' before '!' token
   33 |   if(T[u].l! = -1){
      |     ~      ^
      |            )
main.c:36:12: error: expected ')' before '!' token
   36 |   if(T[u].r! = -1){
      |     ~      ^
      |            )
Language: C

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

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

int getSibling(int u){
  if(tree[u].p==NIL){
    return NIL;
  }
  if(tree[tree[u].p].l!=u && tree[tree[u].p].l!=NIL){
    return tree[tree[u].p].r;
  }
  return NIL;
}
void print(int u){
  int sub,dgree=0;
  printf("node %d: parent = %d, sibling = %d, ",u,tree[u].p,sub = getSibling(u));
  if(tree[u].l!=NIL){
    dgree++;
  }
  if(tree[u].r!=NIL){
    dgree++;
  }
  printf("degree = %d, depth = %d, height = %d, ",dgree,D[u],H[u]);

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

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

int setHeight(int u){
  int h1=0,h2=0;
  if(tree[u].l != NIL){
    h1 = setHeight(tree[u].l) + 1;
  }
  if(tree[u].r != NIL){
    h2 = setHeight(tree[u].r) + 1;
  }
  if(h1>=h2){
    H[u] = h1;
    return H[u];
  }
  else{
    H[u] = h2;
    return H[u];
  }
}

int main(){
  int i,v,l,r,root=0;
  scanf("%d",&n);

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

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


Compiler output:
main.c: In function 'setDepth':
main.c:48:21: error: request for member 'd' in something not a structure or union
   48 |   setDepth(tree[u].r.d+1);
      |                     ^
main.c:48:3: error: too few arguments to function 'setDepth'
   48 |   setDepth(tree[u].r.d+1);
      |   ^~~~~~~~
main.c:42:6: note: declared here
   42 | void setDepth(int u,int d){
      |      ^~~~~~~~
Language: C

#include<stdio.h>

typedef struct{
  int oya,sa,yuu;
}ki;

ki tree[100000];
int Depth[100000];
int Height[100000]
  
void depth(int r,int t){
  if(r==-1)return;_
  Depth[r]=t;
  if(tree[r].yuu!=-1)depth(tree[r].yuu,t+1);
  if(tree[r].sa!=-1)depth(tree[r].sa,t+1);
}

int setHeight(int u){
  int height1=0,height2=0;
  if(tree[u].sa!=-1)height1=setHeight(tree[u].sa)+1;
  if(tree[u].yuu!=-1)height2=setHeight(tree[u].yuu)+1;
  return Height[u]=(h1>h2 ? h1 : h2);
}

int get 



Compiler output:
main.c:9:19: error: expected ';' before 'void'
    9 | int Height[100000]
      |                   ^
      |                   ;
   10 | 
   11 | void depth(int r,int t){
      | ~~~~               
main.c: In function 'depth':
main.c:12:19: error: unknown type name '_'
   12 |   if(r==-1)return;_
      |                   ^
main.c:13:12: error: variable-sized object may not be initialized except with an empty initializer
   13 |   Depth[r]=t;
      |            ^
main.c: In function 'setHeight':
main.c:22:10: error: 'Height' undeclared (first use in this function); did you mean 'height2'?
   22 |   return Height[u]=(h1>h2 ? h1 : h2);
      |          ^~~~~~
      |          height2
main.c:22:10: note: each undeclared identifier is reported only once for each function it appears in
main.c:22:21: error: 'h1' undeclared (first use in this function)
   22 |   return Height[u]=(h1>h2 ? h1 : h2);
      |                     ^~
main.c:22:24: error: 'h2' undeclared (first use in this function)
   22 |   return Height[u]=(h1>h2 ? h1 : h2);
      |                        ^~
main.c: At top level:
main.c:25:1: error: expected '=', ',', ';', 'asm' or '__attribute__' at end of input
   25 | int get
      | ^~~
Language: C

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

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

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

void setDepth(int a,int b){
  if(a==NIL)return;
  D[a]=b;
  setDepth(T[a].left,b+1);
  setDepth(T[a].right,b+1);
}

int setHeight(int n){
  int h1=0,h2=0;
  if(T[n].left!=NIL) h1=setHeight(T[n].left)+1;
  if(T[n].right!=NIL) h2=setHeight(T[n].right)+1;
  return H[n]=(h1>h2?h1:h2);
}

int getSibling(int n){
  if(T[n].parent==NIL)return NIL;
  if(T[T[n].parent].left!=u&&T[T[n].parent].left!=NIL)return T[T[n].parent].left;
  if(T[T[n].parent].right!=u&&T[T[n].parent].right!=NIL)return T[T[n].parent].right;
 return NIL;
}


void print(int u){
  int i,c;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("sibling = %d, ",getSibling(u));
  
  int deg=0;
  if(T[u].left!=NIL)deg++;
  if(T[u].right!=NIL)deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);

  if(T[u].parent==NIL)printf("root\n");
  else if(T[u].left==NIL&&T[u].right==NIL) printf("leaf\n");
  else  printf("internal node\n");
}

int main(){

  int v,l,r,root=0,i;

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

  for(i=0;i<n;i++){
     scanf("%d",&v);
     scanf("%d",&l);
     scanf("%d",&r);
     T[v].left=l;
     T[v].right=r;
     if(l!=NIL)T[l].parent=v;
     if(r!=NIL)T[r].parent=v;
  }
  
  for(i=0;i<n;i++){
    if(T[i].parent==NIL)root=i;
  }
  setDepth(root,0);
  setHeight(root);
  for(i=0;i<n;i++)print(i);
  return 0;
}


Compiler output:
main.c: In function 'getSibling':
main.c:29:27: error: 'u' undeclared (first use in this function)
   29 |   if(T[T[n].parent].left!=u&&T[T[n].parent].left!=NIL)return T[T[n].parent].left;
      |                           ^
main.c:29:27: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include<stdio.h>

#define MAX 10000
#define NIL -1

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

struct Node T[MAX];

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

int main() {
  int i,v,l,r;

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

  for(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].a = v;
    if ( r != NIL )
      T[r].a = v;
  }

  for (i = 0 ; i < n ; i++){
    D[i] = getDepth(i);
    H[i] = 0;
  }

  for (i = 0 ; i < n ; i++){
    if (T[i].l == NIL && T[i].r == NIL) {
      H[i] = 0;
      int p = T[i].p;
      int c = 1;
      while(1){
        if (p == NIL)
          break;
        if (H[p] < c)
          H[p] = c;
        c++;
        a = T[p].a;
      }
    }
  }
  for (i = 0 ; i < n ; i++)
    print(i);
  return 0;
}




Compiler output:
main.c: In function 'main':
main.c:34:12: error: implicit declaration of function 'getDepth' [-Wimplicit-function-declaration]
   34 |     D[i] = getDepth(i);
      |            ^~~~~~~~
main.c:41:19: error: 'struct Node' has no member named 'p'
   41 |       int p = T[i].p;
      |                   ^
main.c:49:9: error: 'a' undeclared (first use in this function)
   49 |         a = T[p].a;
      |         ^
main.c:49:9: note: each undeclared identifier is reported only once for each function it appears in
main.c:54:5: error: implicit declaration of function 'print'; did you mean 'printf'? [-Wimplicit-function-declaration]
   54 |     print(i);
      |     ^~~~~
      |     printf
Language: C

#include<stdio.h>

#define MAX 10000
#define NIL -1

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

struct Node T[MAX];

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

int main() {
  int i,v,l,r;

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

  for(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].a = v;
    if ( r != NIL )
      T[r].a = v;
  }

  for (i = 0 ; i < n ; i++){
    D[i] = getDepth(i);
    H[i] = 0;
  }

  for (i = 0 ; i < n ; i++){
    if (T[i].l == NIL && T[i].r == NIL) {
      H[i] = 0;
      int p = T[i].a;
      int c = 1;
      while(1){
        if (p == NIL)
          break;
        if (H[p] < c)
          H[p] = c;
        c++;
        p = T[p].a;
      }
    }
  }
  for (i = 0 ; i < n ; i++)
    print(i);
  return 0;
}




Compiler output:
main.c: In function 'main':
main.c:34:12: error: implicit declaration of function 'getDepth' [-Wimplicit-function-declaration]
   34 |     D[i] = getDepth(i);
      |            ^~~~~~~~
main.c:54:5: error: implicit declaration of function 'print'; did you mean 'printf'? [-Wimplicit-function-declaration]
   54 |     print(i);
      |     ^~~~~
      |     printf
Language: C

#include<stdio.h>

#define MAX 10000
#define NIL -1

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

struct Node T[MAX];

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

int main() {
  int i,v,l,r;

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

  for(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 (i = 0 ; i < n ; i++){
    D[i] = getDepth(i);
    H[i] = 0;
  }

  for (i = 0 ; i < n ; i++){
    if (T[i].l == NIL && T[i].r == NIL) {
      H[i] = 0;
      int p = T[i].p;
      int c = 1;
      while(1){
        if (p == NIL)
          break;
        if (H[p] < c)
          H[p] = c;
        c++;
        p = T[p].p;
      }
    }
  }
  for (i = 0 ; i < n ; i++)
    print(i);
  return 0;
}




Compiler output:
main.c: In function 'main':
main.c:34:12: error: implicit declaration of function 'getDepth' [-Wimplicit-function-declaration]
   34 |     D[i] = getDepth(i);
      |            ^~~~~~~~
main.c:54:5: error: implicit declaration of function 'print'; did you mean 'printf'? [-Wimplicit-function-declaration]
   54 |     print(i);
      |     ^~~~~
      |     printf
Language: C

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

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

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

  void setDepth(int c,int d){
    if(c==NIL)return;
    D[c]=d;
    setDepth(T[c].left,d+1);
    setDepth(T[c].right,d+1);
  }

  int setHeight(int c){
    int h1=0,h2=0;
    if(T[c].left!=NIL) h1=setHeight(T[c].left)+1;
    if(T[c].right!=NIL) h2=setHeight(T[c].right)+1;
    return H[c]=(h1>h2?h1:h2);
  }

  int getSibling(int u){
    if(T[u].parent==NIL)return NIL;
    if(T[T[u].parent].left!=u&&T[T[u].parent].left!=NIL)return T[T[u].parent].left;
    if(T[T[u].parent].right!=u&&T[T[u].parent].right!=NIL)return T[T[u].parent].right;
   return NIL;
  }


  void print(int u){
    int i,c;
    printf("node %d: ",u);
    printf("parent = %d, ",T[u].parent);
    printf("sibling = %d, ",getSibling(u));
    int deg=0;
    if(T[u].left!=NIL)deg++;
    if(T[u].right!=NIL)deg++;
    printf("degree = %d, ",deg);
    printf("depth = %d, ",D[u]);
    printf("height = %d, ",H[u]);
    if(T[u].parent==NIL)printf("root\n");
    else if(T[u].left==NIL&&T[u].right==NIL) printf("leaf\n");
    else  printf("internal node\n");
  }

  int main(){

    int v,l,r,r=0,i;
    scanf("%d",&n);
    for(i=0;i<n;i++){
      T[i].parent=NIL;
    }
    for(i=0;i<n;i++){
       scanf("%d",&v);
       scanf("%d",&l);
       scanf("%d",&r);
       T[v].left=l;
       T[v].right=r;
       if(l!=NIL)T[l].parent=v;
       if(r!=NIL)T[r].parent=v;
    }
    for(i=0;i<n;i++){
      if(T[i].parent==NIL)r=i;
    }
    setDepth(r,0);
    setHeight(r);
    for(i=0;i<n;i++)print(i);
    return 0;
  }



Compiler output:
main.c: In function 'main':
main.c:53:15: error: redeclaration of 'r' with no linkage
   53 |     int v,l,r,r=0,i;
      |               ^
main.c:53:13: note: previous declaration of 'r' with type 'int'
   53 |     int v,l,r,r=0,i;
      |             ^
Language: C

#include<stdio.h>
#define MAX 100000
struct Node{
  int p,l,r;
};
struct Node T[MAX];
int dp[MAX],f[MAX];

void SetDe(int x,int c){
  if(x==-1)return;
  dp[x]=c;                                                        
  SetDe(T[x].r,c+1);
  SetDe(T[x].l,c+1);
}

int SetHei(int x){
  int k1=0,k2=0;
  if(T[x].l!=-1)k1=SetHei(T[x].l)+1;
  if(T[x].r!=-1)k2=SetHei(T[x].r)+1;
  if(k1>k2)return f[x]=k1;
  else return f[x]=k2;
}
int GetSibling(int x){
  if(T[x].p==-1)return -1;
  if(T[T[x].p].l!=x && T[T[x].p].l!=-1)return T[T[x].p].l;
  if(T[T[x].p].r!=x && T[T[x].p].r!=-1)return T[T[x].p].r;
  return -1;
}
int main(){
  int i,n,id;
  int le,ri,ro,deg;  
  scanf("%d",&n);
  for(i=0;i<n;i++)T[i].p=-1;
  for(i=0;i<n;i++){
    scanf("%d",&id);
    scanf("%d",&le);
    scanf("%d",&ri);
    T[id].l=le;
    T[id].r=ri;
    if(le!=-1)T[le].p=id;
    if(ri!=-1)T[ri].p=id;
  }
  for(i=0;i<n;i++){
    if(T[i].p==-1)root=i;
  } 
  SetDe(ro,0);
  SetHei(ro);
  for(i=0;i<n;i++){
    deg=0;
    printf("node %d: ",i);
    printf("parent = %d, ",T[i].p);
    printf("sibling = %d, ",GetSibling(i));
    if(T[i].l!=-1) deg++;
    if(T[i].r!=-1) deg++;
    printf("degree = %d, ",deg);
    printf("depth = %d, ",dp[i]);
    printf("height = %d, ",f[i]);
    if(T[i].p==-1)printf("root\n");
    else if(T[i].l==-1 && T[i].r==-1)printf("leaf\n");
    else printf("internal node\n");				       
    }
  return 0;
}



Compiler output:
main.c: In function 'main':
main.c:44:19: error: 'root' undeclared (first use in this function); did you mean 'ro'?
   44 |     if(T[i].p==-1)root=i;
      |                   ^~~~
      |                   ro
main.c:44:19: note: each undeclared identifier is reported only once for each function it appears in
Language: C

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

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

 struct node T[MAX];
 int H[MAX];

 int sibl(int u){
          if(T[i].parent==NIL)return NIL;
          int p=T[i].parent;
          if(T[p].left==u)return T[p].right;
          else T[p],left;
          }

 int depth(int u){
          int d=0;
          while(T[u].parent!=NIL){
                  int p=T[u].parent;
                  d++;
                  }
          return d;
          }

 int height(int u){
          int n1=0,n2=0;
          if(T[u].left!=0)n1=height(T[u].left)+1;
          if(T[u].right!=0)n2=height(T[u].right)+1;
          int n=n1>n2?n1:n2;
          H[u]=n;
          }
  
 void print(int n){
         int i;
      for(i=0;i<n;i++){
         printf("node %d: parent = %d, ",&i,&T[i].parent);
         printf("sibling = %d, ",sibl(i));
         (T[i].left!=NIL)?printf("degree = 2, ");printf("degree = 0, ");
         printf("depth = %d, ",depth(i));
         printf("height = %d, ",H[i]);
         if(T[i].parent==NIL)printf("root\n");
         else if(T[i].left==NIL)printf("leaf\n");
         else printf("internal node\n");
         }


 int main(){
         int i,n,k,v,l,r;
         scanf("%d",&n);
         for(i=0;i<n;i++){T[i].parent=T[i].left=T[i].right=NIL;}
         for(i=0;i<n;i++){
                   scanf("%d%d%d",&k,&l,&r);
                   T[k].left=l;
                   T[k].right=r;
                   if(l!=NIL)T[l].parent=k;
                   if(r!=NIL)T[r].parent=k;
                   
                   }
         print(n);
         return 0;
         }


Compiler output:
main.c:11:2: error: expected ';', identifier or '(' before 'struct'
   11 |  struct node T[MAX];
      |  ^~~~~~
main.c: In function 'sibl':
main.c:15:16: error: 'i' undeclared (first use in this function)
   15 |           if(T[i].parent==NIL)return NIL;
      |                ^
main.c:15:16: note: each undeclared identifier is reported only once for each function it appears in
main.c:18:21: error: 'left' undeclared (first use in this function)
   18 |           else T[p],left;
      |                     ^~~~
main.c: In function 'print':
main.c:43:49: error: expected ':' before ';' token
   43 |          (T[i].left!=NIL)?printf("degree = 2, ");printf("degree = 0, ");
      |                                                 ^
      |                                                 :
main.c:66:10: error: expected declaration or statement at end of input
   66 |          }
      |          ^
Language: C

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

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

 struct node T[MAX];
 int H[MAX];

 int sibl(int u){
          if(T[u].parent==NIL)return NIL;
          int p=T[u].parent;
          if(T[p].left==u)return T[p].right;
          else T[p].left;
          }

 int depth(int u){
          int d=0;
          while(T[u].parent!=NIL){
                  int p=T[u].parent;
                  d++;
                  }
          return d;
          }

 int height(int u){
          int n1=0,n2=0;
          if(T[u].left!=0)n1=height(T[u].left)+1;
          if(T[u].right!=0)n2=height(T[u].right)+1;
          int n=n1>n2?n1:n2;
          H[u]=n;
          }
  
 void print(int n){
         int i;
      for(i=0;i<n;i++){
         printf("node %d: parent = %d, ",&i,&T[i].parent);
         printf("sibling = %d, ",sibl(i));
         (T[i].left!=NIL)?printf("degree = 2, ");printf("degree = 0, ");
         printf("depth = %d, ",depth(i));
         printf("height = %d, ",H[i]);
         if(T[i].parent==NIL)printf("root\n");
         else if(T[i].left==NIL)printf("leaf\n");
         else printf("internal node\n");
         }


 int main(){
         int i,n,k,v,l,r;
         scanf("%d",&n);
         for(i=0;i<n;i++){T[i].parent=T[i].left=T[i].right=NIL;}
         for(i=0;i<n;i++){
                   scanf("%d%d%d",&k,&l,&r);
                   T[k].left=l;
                   T[k].right=r;
                   if(l!=NIL)T[l].parent=k;
                   if(r!=NIL)T[r].parent=k;
                   
                   }
         print(n);
         return 0;
         }


Compiler output:
main.c:11:2: error: expected ';', identifier or '(' before 'struct'
   11 |  struct node T[MAX];
      |  ^~~~~~
main.c: In function 'print':
main.c:43:49: error: expected ':' before ';' token
   43 |          (T[i].left!=NIL)?printf("degree = 2, ");printf("degree = 0, ");
      |                                                 ^
      |                                                 :
main.c:66:10: error: expected declaration or statement at end of input
   66 |          }
      |          ^
Language: C

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

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

 struct node T[MAX];
 int H[MAX];

 int sibl(int u){
          if(T[u].parent==NIL)return NIL;
          int p=T[u].parent;
          if(T[p].left==u)return T[p].right;
          else T[p].left;
          }

 int depth(int u){
          int d=0;
          while(T[u].parent!=NIL){
                  int p=T[u].parent;
                  d++;
                  }
          return d;
          }

 int height(int u){
          int n1=0,n2=0;
          if(T[u].left!=0)n1=height(T[u].left)+1;
          if(T[u].right!=0)n2=height(T[u].right)+1;
          int n=n1>n2?n1:n2;
          H[u]=n;
          }
  
 void print(int i){
         
         printf("node %d: parent = %d, ",i,T[i].parent);
         printf("sibling = %d, ",sibl(i));
         (T[i].left!=NIL)?printf("degree = 2, "):printf("degree = 0, ");
         printf("depth = %d, ",depth(i));
         printf("height = %d, ",H[i]);
         if(T[i].parent==NIL)printf("root\n");
         else if(T[i].left==NIL)printf("leaf\n");
         else printf("internal node\n");
         }
      }


 int main(){
         int i,n,k,v,l,r;
         scanf("%d",&n);
         for(i=0;i<n;i++){T[i].parent=T[i].left=T[i].right=NIL;}
         for(i=0;i<n;i++){
                   scanf("%d%d%d",&k,&l,&r);
                   T[k].left=l;
                   T[k].right=r;
                   if(l!=NIL)T[l].parent=k;
                   if(r!=NIL)T[r].parent=k;
                   
                   }
         
         for(i=0;i<n;i++){print(i)};
         return 0;
         }


Compiler output:
main.c:49:7: error: expected identifier or '(' before '}' token
   49 |       }
      |       ^
main.c: In function 'main':
main.c:65:35: error: expected ';' before '}' token
   65 |          for(i=0;i<n;i++){print(i)};
      |                                   ^
      |                                   ;
Language: C

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

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

 struct node T[MAX];
 int H[MAX];

 int sibl(int u){
          if(T[u].parent==NIL)return NIL;
          int p=T[u].parent;
          if(T[p].left==u)return T[p].right;
          else T[p].left;
          }

 int depth(int u){
          int d=0;
          while(T[u].parent!=NIL){
                  int p=T[u].parent;
                  d++;
                  }
          return d;
          }

 int height(int u){
          int n1=0,n2=0;
          if(T[u].left==0)return 0;
          if(T[u].left!=0)n1=height(T[u].left)+1;
          if(T[u].right!=0)n2=height(T[u].right)+1;
          if(n1>n2)return n1;
          else return n2;
          }
  
 void print(int i){
         
         printf("node %d: parent = %d, ",i,T[i].parent);
         printf("sibling = %d, ",sibl(i));
         (T[i].left!=NIL)?printf("degree = 2, "):printf("degree = 0, ");
         printf("depth = %d, ",depth(i));
         printf("height = %d, ",height(i));
         if(T[i].parent==NIL)printf("root\n");
         else if(T[i].left==NIL)printf("leaf\n");
         else printf("internal node\n");
         }
      }


 int main(){
         int i,n,k,v,l,r;
         scanf("%d",&n);
         for(i=0;i<n;i++){T[i].parent=T[i].left=T[i].right=NIL;}
         for(i=0;i<n;i++){
                   scanf("%d%d%d",&k,&l,&r);
                   T[k].left=l;
                   T[k].right=r;
                   if(l!=NIL)T[l].parent=k;
                   if(r!=NIL)T[r].parent=k;
                   
                   }
         
         for(i=0;i<n;i++){print(i)};
         return 0;
         }


Compiler output:
main.c:50:7: error: expected identifier or '(' before '}' token
   50 |       }
      |       ^
main.c: In function 'main':
main.c:66:35: error: expected ';' before '}' token
   66 |          for(i=0;i<n;i++){print(i)};
      |                                   ^
      |                                   ;
Language: C

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

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

 struct node T[MAX];
 int H[MAX];

 int sibl(int u){
          if(T[u].parent==NIL)return NIL;
          int p=T[u].parent;
          if(T[p].left==u)return T[p].right;
          else T[p].left;
          }

 int depth(int u){
          int d=0;
          while(T[u].parent!=NIL){
                  int p=T[u].parent;
                  d++;
                  }
          return d;
          }

 int height(int u){
          int n1=0,n2=0;
          if(T[u].left==0)return 0;
          if(T[u].left!=0)n1=height(T[u].left)+1;
          if(T[u].right!=0)n2=height(T[u].right)+1;
          if(n1>n2)return n1;
          else return n2;
          }
  
 void print(int i){
         
         printf("node %d: parent = %d, ",i,T[i].parent);
         printf("sibling = %d, ",sibl(i));
         (T[i].left!=NIL)?printf("degree = 2, "):printf("degree = 0, ");
         printf("depth = %d, ",depth(i));
         printf("height = %d, ",height(i));
         if(T[i].parent==NIL)printf("root\n");
         else if(T[i].left==NIL)printf("leaf\n");
         else printf("internal node\n");
         }
      


 int main(){
         int i,n,k,v,l,r;
         scanf("%d",&n);
         for(i=0;i<n;i++){T[i].parent=T[i].left=T[i].right=NIL;}
         for(i=0;i<n;i++){
                   scanf("%d%d%d",&k,&l,&r);
                   T[k].left=l;
                   T[k].right=r;
                   if(l!=NIL)T[l].parent=k;
                   if(r!=NIL)T[r].parent=k;
                   
                   }
         
         for(i=0;i<n;i++){print(i)};
         return 0;
         }


Compiler output:
main.c: In function 'main':
main.c:66:35: error: expected ';' before '}' token
   66 |          for(i=0;i<n;i++){print(i)};
      |                                   ^
      |                                   ;
Language: C

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

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

struct Node T[MAX]; 

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

int degree(int x){
	if(T[x].l != NIL && T[x].r != NIL){
		return 2;
	}else if(T[x].l != NIL || T[x].r != NIL){
		return 1;
	}else{
		return 0;
	}
}

int sibling(int p,int x){
	if(p == NIL){
		return NIL;
	} else if(T[p].l == x){
		return T[p].r;
	} else {
		return T[p].l;
	}
}

int height(int x){
	int l_h = 0, r_h = 0;

	if(x == NIL){
		return 0;
	}

	if(T[x].l != NIL){
		l_h = height(T[x].l)+1;
	}
	if(T[x].r != NIL){
		r_h = height(T[x].r)+1;
	}

	if(l_h > r_h){
		return l_h;
	}else{
		return r_h;
	}
}


void print(int u){
	printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, " ,u ,T[u].p ,sibling(T[u].p,u) ,degree(u) ,depth(u) ,height(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");
	}
}

int main(){
	int n,i,id,right,left;

	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%d",&id ,&right ,&left);

		T[right].p = id;
		T[left].p = id;
		T[id].l = right;
		T[id].r = left;
	}

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

Compiler output:
main.c: In function 'print':
main.c:65:33: error: expected ';' before ':' token
   65 |                 printf("root\n"):
      |                                 ^
      |                                 ;