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

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){


}

Node treeMaximum(Node x){


}

Node treeSearch(Node u, int k){


}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;




}

void inorder(Node u){

}
void preorder(Node u){

}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Compiler output:
a.cc: In function 'node* treeMinimum(Node)':
a.cc:18:1: warning: no return statement in function returning non-void [-Wreturn-type]
   18 | }
      | ^
a.cc: In function 'node* treeMaximum(Node)':
a.cc:23:1: warning: no return statement in function returning non-void [-Wreturn-type]
   23 | }
      | ^
a.cc: In function 'node* treeSearch(Node, int)':
a.cc:28:1: warning: no return statement in function returning non-void [-Wreturn-type]
   28 | }
      | ^
a.cc: In function 'node* treeSuccessor(Node)':
a.cc:33:1: warning: no return statement in function returning non-void [-Wreturn-type]
   33 | }
      | ^
a.cc: In function 'void insert(int)':
a.cc:48:13: error: invalid conversion from 'void*' to 'Node' {aka 'node*'} [-fpermissive]
   48 |   z = malloc(sizeof(struct node));
      |       ~~~~~~^~~~~~~~~~~~~~~~~~~~~
      |             |
      |             void*
Language: C++

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left != NIL){
    x = x->left;
  }
  return x;
}

Node treeMaximum(Node x){
  while(x->right != NIL){
    x = x->right;
  }
  return x;
}

Node treeSearch(Node u, int k){
  if(u == NIL || k == u->key){
    return u;
  }
  if(k < u->key){
    return treeSearch(u->left,k);
  } else
    return treeSearch(u->right, k);
}

Node treeSuccessor(Node x){


}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y=x;
    if(z->key < x->key){
      x = x->left;
    } else {
      x = x->right;
    }
  }
  z->parent = y;

  if(y == NIL){
    root = z;
  } else if(z->key < y-> key){
    y->left = z;
  } else{
    y->right = z;
  }
}

void inorder(Node u){
  if(u == NIL)
    return;
  inorder(u->left);
  printf("%d ",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if (u == NIL)
    return;
  printf("%d ",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}



Compiler output:
a.cc: In function 'node* treeSuccessor(Node)':
a.cc:42:1: warning: no return statement in function returning non-void [-Wreturn-type]
   42 | }
      | ^
a.cc: In function 'void insert(int)':
a.cc:49:13: error: invalid conversion from 'void*' to 'Node' {aka 'node*'} [-fpermissive]
   49 |   z = malloc(sizeof(struct node));
      |       ~~~~~~^~~~~~~~~~~~~~~~~~~~~
      |             |
      |             void*
Language: C++

#include<cstdio>//
#include<cstdlib>//  8_A.cpp
#include<string>//
#include<iostream>//
using namespace//  Created by 杵鞭俊 on 2018/07/10.
struct node{
    int key;
    node *right,*left,*parent;
};

node *root,*NIL;

void insert(int k){
    node *y=NIL;
    node *x=root;
    node *z;
    z=(node *)malloc(sizeof(node));

    z->key=k;
    z->left=NIL;
    z->right=NIL;
    
    while(x!=NIL){
        y=x;
        if(z->key<x->key){
            x=x->left;
        
        }else{
            x=x->right;
        }
        
    }
    z->parent=y;
    if(y==NIL){
        root=z;
    }else{
        if(z->key<y->key){
            y->left=z;
        }else{
            y->right=z;
        }
    }
}

void inorder(node *u){
    if(u==NIL) return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}

void preorder(node *u){
    if(u==NIL) return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right)
}



int main(){
    int n,i,x;
    string com;
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        cin >> com;
        if(com=="insert"){
            scanf("%d",&x);
            insert(x);
        }else if(com=="print"){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        
        
        }
    }
    return 0;
}



Compiler output:
a.cc:6:1: error: expected identifier before 'struct'
    6 | struct node{
      | ^~~~~~
a.cc:5:16: error: expected ';' before 'struct'
    5 | using namespace//  Created by 杵鞭俊 on 2018/07/10.
      |                ^
      |                ;
    6 | struct node{
      | ~~~~~~          
a.cc: In function 'void preorder(node*)':
a.cc:56:23: error: expected ';' before '}' token
   56 |     preorder(u->right)
      |                       ^
      |                       ;
   57 | }
      | ~                      
a.cc: In function 'int main()':
a.cc:63:5: error: 'string' was not declared in this scope
   63 |     string com;
      |     ^~~~~~
a.cc:63:5: note: suggested alternatives:
In file included from /usr/include/c++/14/string:41,
                 from a.cc:3:
/usr/include/c++/14/bits/stringfwd.h:77:33: note:   'std::string'
   77 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
/usr/include/c++/14/string:76:11: note:   'std::pmr::string'
   76 |     using string    = basic_string<char>;
      |           ^~~~~~
a.cc:67:9: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   67 |         cin >> com;
      |         ^~~
      |         std::cin
In file included from a.cc:4:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:67:16: error: 'com' was not declared in this scope
   67 |         cin >> com;
      |                ^~~
Language: C++

#include<cstdio>//
#include<cstdlib>//  8_A.cpp
#include<string>//
#include<iostream>//
using namespace std;//  Created by 杵鞭俊 on 2018/07/10.
struct node{
    int key;
    node *right,*left,*parent;
};

node *root,*NIL;

void insert(int k){
    node *y=NIL;
    node *x=root;
    node *z;
    z=(node *)malloc(sizeof(node));

    z->key=k;
    z->left=NIL;
    z->right=NIL;
    
    while(x!=NIL){
        y=x;
        if(z->key<x->key){
            x=x->left;
        
        }else{
            x=x->right;
        }
        
    }
    z->parent=y;
    if(y==NIL){
        root=z;
    }else{
        if(z->key<y->key){
            y->left=z;
        }else{
            y->right=z;
        }
    }
}

void inorder(node *u){
    if(u==NIL) return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}

void preorder(node *u){
    if(u==NIL) return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right)
}



int main(){
    int n,i,x;
    string com;
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        cin >> com;
        if(com=="insert"){
            scanf("%d",&x);
            insert(x);
        }else if(com=="print"){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        
        
        }
    }
    return 0;
}



Compiler output:
a.cc: In function 'void preorder(node*)':
a.cc:56:23: error: expected ';' before '}' token
   56 |     preorder(u->right)
      |                       ^
      |                       ;
   57 | }
      | ~
Language: C++

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left != NIL){
    x = x->left;
  }
  return x;
}

Node treeMaximum(Node x){
  while(x->right != NIL){
    x = x->right;
  }
  return x;
}

Node treeSearch(Node u, int k){
  if(u == NIL || k == u->key){
    return u;
  }
  if(k < u->key){
    return treeSearch(u->left,k);
  } else
    return treeSearch(u->right, k);
}

Node treeSuccessor(Node x){


}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y=x;
    if(z->key < x->key){
      x = x->left;
    } else {
      x = x->right;
    }
  }
  z->parent = y;

  if(y == NIL){
    root = z;
  } else if(z->key < y-> key){
    y->left = z;
  } else{
    y->right = z;
  }
}

void inorder(Node u){
  if(u == NIL){
    return;
  }
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if (u == NIL){
    return;
  }
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}



Compiler output:
a.cc: In function 'node* treeSuccessor(Node)':
a.cc:42:1: warning: no return statement in function returning non-void [-Wreturn-type]
   42 | }
      | ^
a.cc: In function 'void insert(int)':
a.cc:49:13: error: invalid conversion from 'void*' to 'Node' {aka 'node*'} [-fpermissive]
   49 |   z = malloc(sizeof(struct node));
      |       ~~~~~~^~~~~~~~~~~~~~~~~~~~~
      |             |
      |             void*
Language: C++

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left != NIL){
    x = x->left;
  }
  return x;
}

Node treeMaximum(Node x){
  while(x->right != NIL){
    x = x->right;
  }
  return x;
}

Node treeSearch(Node u, int k){
  if(u == NIL || k == u->key){
    return u;
  }
  if(k < u->key){
    return treeSearch(u->left,k);
  } else
    return treeSearch(u->right, k);
}

Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL)
    return treeMinimum(x->right);

  y=x->parent;
  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y;
  Node x;

  if(z->left == NIL || z->right == NIL){
    y = z;
  } else y = treeSuccessor(z);

  if(y->left != NIL){
    x = y->left;
  }else
    x = y->right;

  if(x != NIL)
    x->parent = y->parent;

  if(y->parent == NIL)
    root = x;
  else if(y == y->parent->left)
    y->parent->left = x;
  else
    y->parent->right = x;
  
  if(y != z)
    z->key = y->key; 
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y=x;
    if(z->key < x->key){
      x = x->left;
    } else {
      x = x->right;
    }
  }
  z->parent = y;

  if(y == NIL){
    root = z;
  } else if(z->key < y-> key){
    y->left = z;
  } else{
    y->right = z;
  }
}

void inorder(Node u){
  if(u == NIL){
    return;
  }
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if (u == NIL){
    return;
  }
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Compiler output:
a.cc: In function 'void insert(int)':
a.cc:84:13: error: invalid conversion from 'void*' to 'Node' {aka 'node*'} [-fpermissive]
   84 |   z = malloc(sizeof(struct node));
      |       ~~~~~~^~~~~~~~~~~~~~~~~~~~~
      |             |
      |             void*
Language: C++

#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
using namespace std;

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

Node *root,*NIL;

void insert(int K){
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->let = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x = x->left;
    }else{
      x = x->right;
    }
  }
  z->parent = y;
  if(y==NIL){
    root = z;
  }else{
    if(z->key < y->key){
      y->left = z;
    }else{
      y->right = z;
    }
  }
}

void inorder(Node *u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node *u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n,i,x;
  string com;

  scanf("&d",&n);

  for(i=0;i<n;i++){
    cin >> com;

    if(com == "insert"){
      scanf("%d",&x);
      insert(x);
    }else if(com == "print"){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}



Compiler output:
a.cc: In function 'void insert(int)':
a.cc:20:12: error: 'k' was not declared in this scope
   20 |   z->key = k;
      |            ^
a.cc:21:6: error: 'struct Node' has no member named 'let'; did you mean 'left'?
   21 |   z->let = NIL;
      |      ^~~
      |      left
Language: C++

#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
using namespace std;

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

Node *root,*NIL;

void insert(int k){
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->let = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x = x->left;
    }else{
      x = x->right;
    }
  }
  z->parent = y;
  if(y==NIL){
    root = z;
  }else{
    if(z->key < y->key){
      y->left = z;
    }else{
      y->right = z;
    }
  }
}

void inorder(Node *u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node *u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n,i,x;
  string com;

  scanf("&d",&n);

  for(i=0;i<n;i++){
    cin >> com;

    if(com == "insert"){
      scanf("%d",&x);
      insert(x);
    }else if(com == "print"){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}



Compiler output:
a.cc: In function 'void insert(int)':
a.cc:21:6: error: 'struct Node' has no member named 'let'; did you mean 'left'?
   21 |   z->let = NIL;
      |      ^~~
      |      left
Language: C++

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

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

 Node *B,*NIL;

void insert(int k){
   Node *y = NIL;
   Node *x = B;
   Node *z;

   z = (Node *)malloc(sizeof Node);
   z->key = k;
   z->l = NIL;
   z->r = NIL;

   while(x!=NIL){
     y = x;
     
     if(z->key < x->key){
       x = x->l;
     }
     else x = x->r;
   }
   
   z->p = y;
   if(y == NIL ){
     B=z;
   }
   else if(z->key < y->key){
       y->l = z;
     }
   else y->r = z;
}




void inorder(Node *u){
  if(u==NIL) return;
  inorder(u->l);
  printf(" %d",u->key);
  inorder(u->r);
}

void preorder(Node *u){
  if(u == NIL )return;
  printf(" %d",u->key);
  preorder(u->l);
  preorder(u->r);
}

int main(){
  
  int i,x,y;
  char G[8];
  scanf("%d",&x);
  
  for(i=0;i<x;i++){
    scanf("%s",&G);
    
    if(G[0] == 'i'){
      scanf("%d",&y);
      insert(y);
    }
    
    else if(G[0] == 'p'){
      inorder(B);
      printf("\n");
      preorder(B);
      printf("\n");
    }
  }
  return 0;
}

  



Compiler output:
a.cc:6:3: error: 'Node' does not name a type
    6 |   Node *r,*l,*p;
      |   ^~~~
a.cc: In function 'void insert(int)':
a.cc:16:34: error: expected primary-expression before ')' token
   16 |    z = (Node *)malloc(sizeof Node);
      |                                  ^
a.cc:18:7: error: 'struct Node' has no member named 'l'
   18 |    z->l = NIL;
      |       ^
a.cc:19:7: error: 'struct Node' has no member named 'r'
   19 |    z->r = NIL;
      |       ^
a.cc:25:15: error: 'struct Node' has no member named 'l'
   25 |        x = x->l;
      |               ^
a.cc:27:18: error: 'struct Node' has no member named 'r'
   27 |      else x = x->r;
      |                  ^
a.cc:30:7: error: 'struct Node' has no member named 'p'
   30 |    z->p = y;
      |       ^
a.cc:35:11: error: 'struct Node' has no member named 'l'
   35 |        y->l = z;
      |           ^
a.cc:37:12: error: 'struct Node' has no member named 'r'
   37 |    else y->r = z;
      |            ^
a.cc: In function 'void inorder(Node*)':
a.cc:45:14: error: 'struct Node' has no member named 'l'
   45 |   inorder(u->l);
      |              ^
a.cc:47:14: error: 'struct Node' has no member named 'r'
   47 |   inorder(u->r);
      |              ^
a.cc: In function 'void preorder(Node*)':
a.cc:53:15: error: 'struct Node' has no member named 'l'
   53 |   preorder(u->l);
      |               ^
a.cc:54:15: error: 'struct Node' has no member named 'r'
   54 |   preorder(u->r);
      |               ^
Language: C++

#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

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

Node *root, *NIL;

void insert(int k){
  Node *x = root,*y = NIL, *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->l = NIL;
  z->r = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->l;
    }
    else{
      x = x->r;
    }
  }

  z->p = y;
  if(y == NIL){
    root = z;
  }
  else{
    if(z->key < y->key){
      y->l = z;
    }
    else{
      y->r = z;
    }
  }
}

void inorder(Node *u){
  if(u == NIL) return;
  printf(" %d", u->key);
  preoder(u->l);
  preoder(u->r);
}


int main(){
  int n, i, x;
  char com;

  scanf("%d", &n);

  for(i = 0 ; i < n ; i++){
    cin >> com;
    if(com == "insert"){
      scanf("%d", &x);
      insert(x);
    }
    else if(com == "print"){
      inorder(root);
      printf("\n");
      preoder(root);
      printf("\n");
    }
  }
  return 0;
}


Compiler output:
a.cc: In function 'void inorder(Node*)':
a.cc:49:3: error: 'preoder' was not declared in this scope
   49 |   preoder(u->l);
      |   ^~~~~~~
a.cc: In function 'int main()':
a.cc:62:12: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   62 |     if(com == "insert"){
      |        ~~~~^~~~~~~~~~~
a.cc:66:17: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   66 |     else if(com == "print"){
      |             ~~~~^~~~~~~~~~
a.cc:69:7: error: 'preoder' was not declared in this scope
   69 |       preoder(root);
      |       ^~~~~~~
Language: C++

#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

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

Node *root, *NIL;

void insert(int k){
  Node *x = root,*y = NIL, *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->l = NIL;
  z->r = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->l;
    }
    else{
      x = x->r;
    }
  }

  z->p = y;
  if(y == NIL){
    root = z;
  }
  else{
    if(z->key < y->key){
      y->l = z;
    }
    else{
      y->r = z;
    }
  }
}

void inorder(Node *u){
  if(u == NIL) return;
  inoder(u->l);
  printf(" %d", u->key);
  inorder(u->r);
}

void preoder(Node *u){
  if(u == NIL) return;    
  printf(" %d", u->key);    
  preoder(u->l);
  preoder(u->r);
}


int main(){
  int n, i, x;
  char com;

  scanf("%d", &n);

  for(i = 0 ; i < n ; i++){
    cin >> com;
    if(com == "insert"){
      scanf("%d", &x);
      insert(x);
    }
    else if(com == "print"){
      inorder(root);
      printf("\n");
      preoder(root);
      printf("\n");
    }
  }
  return 0;
}


Compiler output:
a.cc: In function 'void inorder(Node*)':
a.cc:48:3: error: 'inoder' was not declared in this scope; did you mean 'inorder'?
   48 |   inoder(u->l);
      |   ^~~~~~
      |   inorder
a.cc: In function 'int main()':
a.cc:69:12: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   69 |     if(com == "insert"){
      |        ~~~~^~~~~~~~~~~
a.cc:73:17: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   73 |     else if(com == "print"){
      |             ~~~~^~~~~~~~~~
Language: C++

#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

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

Node *root, *NIL;

void insert(int k){
  Node *x = root,*y = NIL, *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->l = NIL;
  z->r = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->l;
    }
    else{
      x = x->r;
    }
  }

  z->p = y;
  if(y == NIL){
    root = z;
  }
  else{
    if(z->key < y->key){
      y->l = z;
    }
    else{
      y->r = z;
    }
  }
}

void inorder(Node *u){
  if(u == NIL) return;
  inoder(u->l);
  printf(" %d", u->key);
  inorder(u->r);
}

void preorder(Node *u){
  if(u == NIL) return;    
  printf(" %d", u->key);    
  preoder(u->l);
  preoder(u->r);
}


int main(){
  int n, i, x;
  char com;

  scanf("%d", &n);

  for(i = 0 ; i < n ; i++){
    cin >> com;
    if(com == "insert"){
      scanf("%d", &x);
      insert(x);
    }
    else if(com == "print"){
      inorder(root);
      printf("\n");
      preoder(root);
      printf("\n");
    }
  }
  return 0;
}


Compiler output:
a.cc: In function 'void inorder(Node*)':
a.cc:48:3: error: 'inoder' was not declared in this scope; did you mean 'inorder'?
   48 |   inoder(u->l);
      |   ^~~~~~
      |   inorder
a.cc: In function 'void preorder(Node*)':
a.cc:56:3: error: 'preoder' was not declared in this scope; did you mean 'preorder'?
   56 |   preoder(u->l);
      |   ^~~~~~~
      |   preorder
a.cc: In function 'int main()':
a.cc:69:12: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   69 |     if(com == "insert"){
      |        ~~~~^~~~~~~~~~~
a.cc:73:17: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   73 |     else if(com == "print"){
      |             ~~~~^~~~~~~~~~
a.cc:76:7: error: 'preoder' was not declared in this scope; did you mean 'preorder'?
   76 |       preoder(root);
      |       ^~~~~~~
      |       preorder
Language: C++

#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

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

Node *root, *NIL;

void insert(int k){
  Node *x = root,*y = NIL, *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->l = NIL;
  z->r = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->l;
    }
    else{
      x = x->r;
    }
  }

  z->p = y;
  if(y == NIL){
    root = z;
  }
  else{
    if(z->key < y->key){
      y->l = z;
    }
    else{
      y->r = z;
    }
  }
}

void inorder(Node *u){
  if(u == NIL) return;
  inoder(u->l);
  printf(" %d", u->key);
  inorder(u->r);
}

void preorder(Node *u){
  if(u == NIL) return;    
  printf(" %d", u->key);    
  preoder(u->l);
  preoder(u->r);
}


int main(){
  int n, i, x;
  string com;

  scanf("%d", &n);

  for(i = 0 ; i < n ; i++){
    cin >> com;
    if(com == "insert"){
      scanf("%d", &x);
      insert(x);
    }
    else if(com == "print"){
      inorder(root);
      printf("\n");
      preoder(root);
      printf("\n");
    }
  }
  return 0;
}


Compiler output:
a.cc: In function 'void inorder(Node*)':
a.cc:48:3: error: 'inoder' was not declared in this scope; did you mean 'inorder'?
   48 |   inoder(u->l);
      |   ^~~~~~
      |   inorder
a.cc: In function 'void preorder(Node*)':
a.cc:56:3: error: 'preoder' was not declared in this scope; did you mean 'preorder'?
   56 |   preoder(u->l);
      |   ^~~~~~~
      |   preorder
a.cc: In function 'int main()':
a.cc:76:7: error: 'preoder' was not declared in this scope; did you mean 'preorder'?
   76 |       preoder(root);
      |       ^~~~~~~
      |       preorder
Language: C++

#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

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

Node *root, *NIL;

void insert(int k){
  Node *x = root,*y = NIL, *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->l = NIL;
  z->r = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->l;
    }
    else{
      x = x->r;
    }
  }

  z->p = y;
  if(y == NIL){
    root = z;
  }
  else{
    if(z->key < y->key){
      y->l = z;
    }
    else{
      y->r = z;
    }
  }
}

void inorder(Node *u){
  if(u == NIL) return;
  inorder(u->l);
  printf(" %d", u->key);
  inorder(u->r);
}

void preorder(Node *u){
  if(u == NIL) return;    
  printf(" %d", u->key);    
  preoder(u->l);
  preoder(u->r);
}


int main(){
  int n, i, x;
  string com;

  scanf("%d", &n);

  for(i = 0 ; i < n ; i++){
    cin >> com;
    if(com == "insert"){
      scanf("%d", &x);
      insert(x);
    }
    else if(com == "print"){
      inorder(root);
      printf("\n");
      preoder(root);
      printf("\n");
    }
  }
  return 0;
}


Compiler output:
a.cc: In function 'void preorder(Node*)':
a.cc:56:3: error: 'preoder' was not declared in this scope; did you mean 'preorder'?
   56 |   preoder(u->l);
      |   ^~~~~~~
      |   preorder
a.cc: In function 'int main()':
a.cc:76:7: error: 'preoder' was not declared in this scope; did you mean 'preorder'?
   76 |       preoder(root);
      |       ^~~~~~~
      |       preorder
Language: C++

#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

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

Node *root, *NIL;

void insert(int k){
  Node *x = root,*y = NIL, *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->l = NIL;
  z->r = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->l;
    }
    else{
      x = x->r;
    }
  }

  z->p = y;
  if(y == NIL){
    root = z;
  }
  else{
    if(z->key < y->key){
      y->l = z;
    }
    else{
      y->r = z;
    }
  }
}

void inorder(Node *u){
  if(u == NIL) return;
  inorder(u->l);
  printf(" %d", u->key);
  inorder(u->r);
}

void preorder(Node *u){
  if(u == NIL) return;    
  printf(" %d", u->key);    
  preorder(u->l);
  preoder(u->r);
}


int main(){
  int n, i, x;
  string com;

  scanf("%d", &n);

  for(i = 0 ; i < n ; i++){
    cin >> com;
    if(com == "insert"){
      scanf("%d", &x);
      insert(x);
    }
    else if(com == "print"){
      inorder(root);
      printf("\n");
      preoder(root);
      printf("\n");
    }
  }
  return 0;
}


Compiler output:
a.cc: In function 'void preorder(Node*)':
a.cc:57:3: error: 'preoder' was not declared in this scope; did you mean 'preorder'?
   57 |   preoder(u->r);
      |   ^~~~~~~
      |   preorder
a.cc: In function 'int main()':
a.cc:76:7: error: 'preoder' was not declared in this scope; did you mean 'preorder'?
   76 |       preoder(root);
      |       ^~~~~~~
      |       preorder
Language: C++

#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

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

Node *root, *NIL;

void insert(int k){
  Node *x = root,*y = NIL, *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->l = NIL;
  z->r = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->l;
    }
    else{
      x = x->r;
    }
  }

  z->p = y;
  if(y == NIL){
    root = z;
  }
  else{
    if(z->key < y->key){
      y->l = z;
    }
    else{
      y->r = z;
    }
  }
}

void inorder(Node *u){
  if(u == NIL) return;
  inorder(u->l);
  printf(" %d", u->key);
  inorder(u->r);
}

void preorder(Node *u){
  if(u == NIL) return;    
  printf(" %d", u->key);    
  preorder(u->l);
  preorder(u->r);
}


int main(){
  int n, i, x;
  string com;

  scanf("%d", &n);

  for(i = 0 ; i < n ; i++){
    cin >> com;
    if(com == "insert"){
      scanf("%d", &x);
      insert(x);
    }
    else if(com == "print"){
      inorder(root);
      printf("\n");
      preoder(root);
      printf("\n");
    }
  }
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:76:7: error: 'preoder' was not declared in this scope; did you mean 'preorder'?
   76 |       preoder(root);
      |       ^~~~~~~
      |       preorder
Language: C++

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

#define N_MAX 500001

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

typedef struct node *Node;
Node root = NULL;

void insert(int k){
    Node y = NULL;
    Node x = root;
    Node z;
    
    z = malloc(sizeof(struct node));
    z->key = k;
    z->right = NULL;
    z->left = NULL;
    while(x != NULL){
        y = x;
        if(z->key < x->key){
            x = x->left;
        }else{
            x = x->right;
        }
    }
    z->parent = y;

    if(y == NULL){
        root = z;
    }else if(z->key < y->key){
        y->left = z;
    }else{
        y->right = z;
    }
}

void ino(Node u){
 
  if(u->left != NULL){
 
    ino(u->left);
  }
 
  printf(" %d",u->key);
 
  if(u->right != NULL){
     
    ino(u->right);
  }
 
}
void pre(Node u){
 
  printf(" %d",u->key);
   
  if(u->left != NULL){
    pre(u->left);
  }
   
  if(u->right != NULL){
    pre(u->right);
  }
   
}

int main(){
    int n, i, x;
    char com[20];
    scanf("%d", &n);
    
    
    for ( i = 0; i < n; i++ ){
        scanf("%s", com);
        if ( com[0] == 'i' ){
            scanf("%d", &x);
            insert(x);
        } else if ( com[0] == 'p' ){
            ino(root);
            printf("\n");
            pre(root);
        } 
    }
    return 0;
}






Compiler output:
a.cc: In function 'void insert(int)':
a.cc:21:15: error: invalid conversion from 'void*' to 'Node' {aka 'node*'} [-fpermissive]
   21 |     z = malloc(sizeof(struct node));
      |         ~~~~~~^~~~~~~~~~~~~~~~~~~~~
      |               |
      |               void*
Language: C++

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

#define N_MAX 500001

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

typedef struct node *Node;
Node root = NULL;

void insert(int k){
    Node y = NULL;
    Node x = root;
    Node z;
    
    z = malloc(sizeof(struct node));
    z->key = k;
    z->right = NULL;
    z->left = NULL;
    while(x != NULL){
        y = x;
        if(z->key < x->key){
            x = x->left;
        }else{
            x = x->right;
        }
    }
    z->parent = y;

    if(y == NULL){
        root = z;
    }else if(z->key < y->key){
        y->left = z;
    }else{
        y->right = z;
    }
}

void ino(Node u){
 
  if(u->left != NULL){
 
    ino(u->left);
  }
 
  printf(" %d",u->key);
 
  if(u->right != NULL){
     
    ino(u->right);
  }
 
}
void pre(Node u){
 
  printf(" %d",u->key);
   
  if(u->left != NULL){
    pre(u->left);
  }
   
  if(u->right != NULL){
    pre(u->right);
  }
   
}

int main(){
    int n, i, x;
    char com[20];
    scanf("%d", &n);
    
    
    for ( i = 0; i < n; i++ ){
        scanf("%s", com);
        if ( com[0] == 'i' ){
            scanf("%d", &x);
            insert(x);
        } else if ( com[0] == 'p' ){
            ino(root);
            printf("\n");
            pre(root);
            printf("\n");
        } 
    }
    return 0;
}






Compiler output:
a.cc: In function 'void insert(int)':
a.cc:21:15: error: invalid conversion from 'void*' to 'Node' {aka 'node*'} [-fpermissive]
   21 |     z = malloc(sizeof(struct node));
      |         ~~~~~~^~~~~~~~~~~~~~~~~~~~~
      |               |
      |               void*
Language: C++

#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

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

Node *root, *NIL;

void insert(int k){
Node *y = NIL;
Node *x = root;
Node *z;

z = (Node *)malloc(sizeof(Node));
z->key = k;
z->left = NIL;
z->right = NIL;

while(x != NIL){
    y = x;
    if(z->key < x->key){
        x = x->left;
    }
    else{
        x = x->right;
    }
}
z->parent = y;
if( y == NIL ){
    root = z;
}
else{
    if(z->key < y -> key){
        y->left = z;
    }
    else{
        y->right = z;
    }
}
}

void inoder(Node *u){
if( u == NIL)return;
inoder(u->left);
printf(" %d",u->key);
inoder(u->right);
}

void preorder(Node *u){
if(u == NIL)return;
printf(" %d",u->key);
preorder(u->left);
preorder(u->right);
}
int main() {
int n,i,x;
string com;

scanf("%d",&n);

for(i=0 ; i<n ; i++){
    cin >> com;
    if(com == "insert"){
scanf("%d",&x);
insert(x);
    }
    else if (com == "print"){
    inorder(root);
    printf("\n");
    preorder(root);
    printf("\n")
    }   
}
return 0;
}





Compiler output:
a.cc: In function 'int main()':
a.cc:73:5: error: 'inorder' was not declared in this scope; did you mean 'inoder'?
   73 |     inorder(root);
      |     ^~~~~~~
      |     inoder
a.cc:76:17: error: expected ';' before '}' token
   76 |     printf("\n")
      |                 ^
      |                 ;
   77 |     }
      |     ~
Language: C++

#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

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

Node *root, *NIL;

void insert(int k){
Node *y = NIL;
Node *x = root;
Node *z;

z = (Node *)malloc(sizeof(Node));
z->key = k;
z->left = NIL;
z->right = NIL;

while(x != NIL){
    y = x;
    if(z->key < x->key){
        x = x->left;
    }
    else{
        x = x->right;
    }
}
z->parent = y;
if( y == NIL ){
    root = z;
}
else{
    if(z->key < y -> key){
        y->left = z;
    }
    else{
        y->right = z;
    }
}
}

void inorder(Node *u){
if( u == NIL)return;
inorder(u->left);
printf(" %d",u->key);
inoder(u->right);
}

void preorder(Node *u){
if(u == NIL)return;
printf(" %d",u->key);
preorder(u->left);
preorder(u->right);
}
int main() {
int n,i,x;
string com;

scanf("%d",&n);

for(i=0 ; i<n ; i++){
    cin >> com;
    if(com == "insert"){
scanf("%d",&x);
insert(x);
    }
    else if (com == "print"){
    inorder(root);
    printf("\n");
    preorder(root);
    printf("\n")
    }   
}
return 0;
}





Compiler output:
a.cc: In function 'void inorder(Node*)':
a.cc:51:1: error: 'inoder' was not declared in this scope; did you mean 'inorder'?
   51 | inoder(u->right);
      | ^~~~~~
      | inorder
a.cc: In function 'int main()':
a.cc:76:17: error: expected ';' before '}' token
   76 |     printf("\n")
      |                 ^
      |                 ;
   77 |     }
      |     ~
Language: C++

#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

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

Node *root, *NIL;

void insert(int k){
Node *y = NIL;
Node *x = root;
Node *z;

z = (Node *)malloc(sizeof(Node));
z->key = k;
z->left = NIL;
z->right = NIL;

while(x != NIL){
    y = x;
    if(z->key < x->key){
        x = x->left;
    }
    else{
        x = x->right;
    }
}
z->parent = y;
if( y == NIL ){
    root = z;
}
else{
    if(z->key < y -> key){
        y->left = z;
    }
    else{
        y->right = z;
    }
}
}

void inorder(Node *u){
if( u == NIL)return;
inorder(u->left);
printf(" %d",u->key);
inorder(u->right);
}

void preorder(Node *u){
if(u == NIL)return;
printf(" %d",u->key);
preorder(u->left);
preorder(u->right);
}

int main() {
int n,i,x;
string com;

scanf("%d",&n);

for(i=0 ; i<n ; i++){
    cin >> com;
    if(com == "insert"){
scanf("%d",&x);
insert(x);
    }
    else if (com == "print"){
    inorder(root);
    printf("\n");
    preorder(root);
    printf("\n")
    }   
}
return 0;
}





Compiler output:
a.cc: In function 'int main()':
a.cc:77:17: error: expected ';' before '}' token
   77 |     printf("\n")
      |                 ^
      |                 ;
   78 |     }
      |     ~
Language: C++

#include<csdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

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

Node *root,*NIL;

void insert(int k){
  Node *y=NIL;
  Node *x=root;
  Node *z;

  z=(Node *)malloc(sizeof(Node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;

  while(x!=NIL){
    y=x;
    if(z->key<x->key){
      x=x->left;
    }else{
      x=x->right;
    }
  }

  z->parent=y;
  if(y==NIL){
    root=z;
  }else{
    if(z->key<y->key){
      y->left=z;
    }else{
      y->right=z;
    }
  }
}

void inorder(Node *u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node *u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n,i,x;
  string com;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    cin>>com;
    if(com=="insert"){
      scanf("%d",&x);
      insert(x);
    }else if(com=="print"){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}



Compiler output:
a.cc:1:9: fatal error: csdio: No such file or directory
    1 | #include<csdio>
      |         ^~~~~~~
compilation terminated.
Language: C++

#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

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

Node*root,*NIL;

void insert(int k){
    Node *y=NIL;
    Node *x=root;
    Node *z;

    z=(Node *)malloc(sizeof(Node));
    z->key=k;
    z->l=NIL;
    z->r=NIL;
    
    while(x!=NIL){
        y=x;
        if(z->key<x->key){
            x=x->l;
        }
        else {
            x=x->r;
        }
    }
    z->p=y;
    if(y==NIL){
        root=z;
    }
    else {
        if(z->key<y->key){
            y->l=z;
        } 
        else{
            y->r=z;
        }
    }
}
 
void inorder(Node *u){
     if(u==NIL)return;
     inorder(u->l);
     printg(" %d",u->key);
     inorder(u->r);
}
 void preorder(Node *u){
     if(u==NIL)return;
     printg(" %d",u->key);
     preorder(u->l);
     preorder(u->r);
}

int main(){
    int n,i,x;
    string com;
    
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        cin>>com;
        if(com=="insert"){
            scanf("%d",&x);
            insert(x);
        }
        else ic(com=="print");
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
    return 0;
}


Compiler output:
a.cc: In function 'void inorder(Node*)':
a.cc:50:6: error: 'printg' was not declared in this scope; did you mean 'printf'?
   50 |      printg(" %d",u->key);
      |      ^~~~~~
      |      printf
a.cc: In function 'void preorder(Node*)':
a.cc:55:6: error: 'printg' was not declared in this scope; did you mean 'printf'?
   55 |      printg(" %d",u->key);
      |      ^~~~~~
      |      printf
a.cc: In function 'int main()':
a.cc:72:14: error: 'ic' was not declared in this scope; did you mean 'i'?
   72 |         else ic(com=="print");
      |              ^~
      |              i
a.cc: At global scope:
a.cc:79:5: error: expected unqualified-id before 'return'
   79 |     return 0;
      |     ^~~~~~
a.cc:80:1: error: expected declaration before '}' token
   80 | }
      | ^
Language: C++

#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

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

Node*root,*NIL;

void insert(int k){
    Node *y=NIL;
    Node *x=root;
    Node *z;

    z=(Node *)malloc(sizeof(Node));
    z->key=k;
    z->l=NIL;
    z->r=NIL;
    
    while(x!=NIL){
        y=x;
        if(z->key<x->key){
            x=x->l;
        }
        else {
            x=x->r;
        }
    }
    z->p=y;
    if(y==NIL){
        root=z;
    }
    else {
        if(z->key<y->key){
            y->l=z;
        } 
        else{
            y->r=z;
        }
    }
}
 
void inorder(Node *u){
     if(u==NIL)return;
     inorder(u->l);
     printf(" %d",u->key);
     inorder(u->r);
}
 void preorder(Node *u){
     if(u==NIL)return;
     printf(" %d",u->key);
     preorder(u->l);
     preorder(u->r);
}

int main(){
    int n,i,x;
    string com;
    
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        cin>>com;
        if(com=="insert"){
            scanf("%d",&x);
            insert(x);
        }
        else ic(com=="print");
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:72:14: error: 'ic' was not declared in this scope; did you mean 'i'?
   72 |         else ic(com=="print");
      |              ^~
      |              i
a.cc: At global scope:
a.cc:79:5: error: expected unqualified-id before 'return'
   79 |     return 0;
      |     ^~~~~~
a.cc:80:1: error: expected declaration before '}' token
   80 | }
      | ^
Language: C++

#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

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

Node*root,*NIL;

void insert(int k){
    Node *y=NIL;
    Node *x=root;
    Node *z;

    z=(Node *)malloc(sizeof(Node));
    z->key=k;
    z->l=NIL;
    z->r=NIL;
    
    while(x!=NIL){
        y=x;
        if(z->key<x->key){
            x=x->l;
        }
        else {
            x=x->r;
        }
    }
    z->p=y;
    if(y==NIL){
        root=z;
    }
    else {
        if(z->key<y->key){
            y->l=z;
        } 
        else{
            y->r=z;
        }
    }
}
 
void inorder(Node *u){
     if(u==NIL)return;
     inorder(u->l);
     printf(" %d",u->key);
     inorder(u->r);
}
 void preorder(Node *u){
     if(u==NIL)return;
     printf(" %d",u->key);
     preorder(u->l);
     preorder(u->r);
}

int main(){
    int n,i,x;
    string com;
    
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        cin>>com;
        if(com=="insert"){
            scanf("%d",&x);
            insert(x);
        }
        else if(com=="print");
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
    return 0;
}


Compiler output:
a.cc:79:5: error: expected unqualified-id before 'return'
   79 |     return 0;
      |     ^~~~~~
a.cc:80:1: error: expected declaration before '}' token
   80 | }
      | ^
Language: C++



from io import StringIO
class BinaryTree:

    class Node:
        def __init__(self, key):
            self.key = key
            self.left = None
            self.right = None
            self.parent = None


    def __init__(self):
        self.root = None
        self.output = StringIO()

    def insert(self, key):
        if self.root is None:
            self.root = self.Node(key)
        else:
            root = self.root
            temp = None
            while True:
                temp = root
                if key > root.key:
                    root = root.right
                    if root is None:
                        temp.right = self.Node(key)
                        break
                else:
                    root = root.left
                    if root is None:
                        temp.left = self.Node(key)
                        break

    def ini_print_inorder(self):
        self.output = StringIO()
        self.print_inorder(self.root)
        return self.output.getvalue()

    def ini_print_preorder(self):
        self.output = StringIO()
        self.print_preorder(self.root)
        return self.output.getvalue()

    def print_inorder(self, node):
        if node is not None:
            self.print_inorder(node.left)
            print(node.key, end = " ", file = self.output)
            self.print_inorder(node.right)

    def print_preorder(self, node):
        if node is not None:
            print(node.key, end = " ", file = self.output)
            self.print_preorder(node.left)
            self.print_preorder(node.right)

    def test_insert(self, keys):
        for k in keys:
            self.insert(k)

length = int(input())
b = BinaryTree()
for _ in range(length):
    comm = input()
    if comm[0] == "i":
        com, num = comm.split(" ")
        b.insert(int(num))
    else:
        print(" ", end = "")
        print((b.ini_print_inorder())[:-1])
        print(b.ini_print_preorder()[:-1])



Compiler output:
a.cc:3:1: error: 'from' does not name a type
    3 | from io import StringIO
      | ^~~~
Language: C++

class BinaryTree:

    from io import StringIO
    
    class Node:
        def __init__(self, key):
            self.key = key
            self.left = None
            self.right = None
            self.parent = None


    def __init__(self):
        self.root = None
        self.output = StringIO()

    def insert(self, key):
        if self.root is None:
            self.root = self.Node(key)
        else:
            root = self.root
            temp = None
            while True:
                temp = root
                if key > root.key:
                    root = root.right
                    if root is None:
                        temp.right = self.Node(key)
                        break
                else:
                    root = root.left
                    if root is None:
                        temp.left = self.Node(key)
                        break

    def ini_print_inorder(self):
        self.output = StringIO()
        self.print_inorder(self.root)
        return self.output.getvalue()

    def ini_print_preorder(self):
        self.output = StringIO()
        self.print_preorder(self.root)
        return self.output.getvalue()

    def print_inorder(self, node):
        if node is not None:
            self.print_inorder(node.left)
            print(node.key, end = " ", file = self.output)
            self.print_inorder(node.right)

    def print_preorder(self, node):
        if node is not None:
            print(node.key, end = " ", file = self.output)
            self.print_preorder(node.left)
            self.print_preorder(node.right)

    def test_insert(self, keys):
        for k in keys:
            self.insert(k)

length = int(input())
b = BinaryTree()
for _ in range(length):
    comm = input()
    if comm[0] == "i":
        com, num = comm.split(" ")
        b.insert(int(num))
    else:
        print(" ", end = "")
        print((b.ini_print_inorder())[:-1])
        print(" ", end = "")
        print(b.ini_print_preorder()[:-1])


Compiler output:
a.cc:3:10: error: expected class-name before 'io'
    3 |     from io import StringIO
      |          ^~
a.cc:3:10: error: expected '{' before 'io'
a.cc:3:13: error: expected initializer before 'import'
    3 |     from io import StringIO
      |             ^~~~~~