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

#include<stdio.h>
#include<stdlib.h>
#define MAX 500001
#define NIL NULL
struct N{
  int key;
  struct N *parent;
  struct N *left;
  struct N *right;
};
typedef struct N * node;

void insert(int);
void ino(node);
void pr(node);

node r;

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

void insert(int n){
  node x = NIL;
  node y = r;
  node z;
  z = malloc(sizeof(struct N));
  z->key = n;
  z->left = NIL;
  z->right = NIL;
  while(y!=NIL){
    x = y;
    if(z->key < y->key) y = y->left;
    else y = y->right;
  }
  z->parent = x;
  if(x == NIL)r = z;
  else if( z->key < x->key) x->left = z;
  else x->right = z;
}

void ino(node a){
  if(a!=NIL){
    ino(a->left);
    printf(" %d", a->key);
    ino(a->right);
}
}

void pr(node a){
  if(a!=NIL){
    printf(" %d" , a->key);
    pr(a->left);
    pr(a->right);
  }
}

Compiler output:
main.c: In function 'main':
main.c:31:18: error: expected expression before '[' token
   31 |     else if(c == [0]){
      |                  ^
Language: C

#include<stdio.h>
#include<stdlib.h>
#define MAX 500001
#define NIL NULL
struct N{
  int key;
  struct N *parent;
  struct N *left;
  struct N *right;
};
typedef struct N * node;

void insert(int);
void ino(node);
void pr(node);
node *find(node *, int);
node r;

int main(){
  int i,n,x;
  char c[20];
  scanf("%d", &n);
  
  for(i = 0; i < n; i++){
    scanf("%s", c);
  
    if(c[0] == 'i'){
      scanf("%d", &x);
      insert(x);
    }
    else if(c[0] == 'f'){
      scanf ("%d" , &x);
      node *t = find(r , x);
      if(t!= NIL)printf("yes\n");
      else printf("no\n");
    }
    else if(c[0] == 'p'){
      ino(r);
      printf("\n");
      pr(r);
       printf("\n");
    }
  }
  return 0;
}

void insert(int n){
  node x = NIL;
  node y = r;
  node z;
  z = malloc(sizeof(struct N));
  z->key = n;
  z->left = NIL;
  z->right = NIL;
  while(y!=NIL){
    x = y;
    if(z->key < y->key) y = y->left;
    else y = y->right;
  }
  z->parent = x;
  if(x == NIL)r = z;
  else if( z->key < x->key) x->left = z;
  else x->right = z;
}

void ino(node a){
  if(a!=NIL){
    ino(a->left);
    printf(" %d", a->key);
    ino(a->right);
}
}

void pr(node a){
  if(a!=NIL){
    printf(" %d" , a->key);
    pr(a->left);
    pr(a->right);
  }
}
node * find(node *a,int n){
  while(a!=NIL && n!=a->key){
    if(n < a->key)  a = a->left;
    else a = a->right;
  }
  return a;
}

Compiler output:
main.c: In function 'main':
main.c:33:22: error: passing argument 1 of 'find' from incompatible pointer type [-Wincompatible-pointer-types]
   33 |       node *t = find(r , x);
      |                      ^
      |                      |
      |                      node {aka struct N *}
main.c:16:12: note: expected 'struct N **' but argument is of type 'node' {aka 'struct N *'}
   16 | node *find(node *, int);
      |            ^~~~~~
main.c: In function 'find':
main.c:82:23: error: 'a' is a pointer to pointer; did you mean to dereference it before applying '->' to it?
   82 |   while(a!=NIL && n!=a->key){
      |                       ^~
      |                      -
      |                      (*a)
main.c:83:13: error: 'a' is a pointer to pointer; did you mean to dereference it before applying '->' to it?
   83 |     if(n < a->key)  a = a->left;
      |             ^~
      |            -
      |            (*a)
main.c:83:26: error: 'a' is a pointer to pointer; did you mean to dereference it before applying '->' to it?
   83 |     if(n < a->key)  a = a->left;
      |                          ^~
      |                         -
      |                         (*a)
main.c:84:15: error: 'a' is a pointer to pointer; did you mean to dereference it before applying '->' to it?
   84 |     else a = a->right;
      |               ^~
      |              -
      |              (*a)
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;
  
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->left != NIL){
    inorder(u->left);
  }
  printf(" %d",u->key);
  if(u->right != NIL){
    inorder(u->right);
  }
  
}
void preorder(Node u){
  printf(" %d",u->key);
  if(u->left!= NIL){
    preorder(u->left);
  }
  if(u->right!= NIL){
    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:
main.c: In function 'main':
main.c:74:16: error: implicit declaration of function 'treeSearch' [-Wimplicit-function-declaration]
   74 |       Node t = treeSearch(root, x);
      |                ^~~~~~~~~~
main.c:74:16: error: initialization of 'Node' {aka 'struct node *'} from 'int' makes pointer from integer without a cast [-Wint-conversion]
Language: C

#include<stdio.h>
#include<stdlib.h>
#define NIL NULL
typedef struct Node{
  int key;
  struct Node *right,*left,*parent;
}Node;

Node *root;

Node *find(Node *u,int k){
  while(u!=NIL && k != u->key){
    if(k<u->key)u=u->left;
    else u=u->right;
  }
  return u;
}

void insert(int k){
  Node *y=NIL;
  Node *x=root;
  Node *z;
  z=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);#include<stdio.h>
#include<stdlib.h>
#define NIL NULL
typedef struct Node{
  int key;
  struct Node *right,*left,*parent;
}Node;

Node *root;

void insert(int k){
  Node *y=NIL;
  Node *x=root;
  Node *z;
  z=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;
  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'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
      }
  }
  return 0;
}

}

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=find(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:
main.c: In function 'inorder':
main.c:51:21: error: stray '#' in program
   51 |   inorder(u->right);#include<stdio.h>
      |                     ^
main.c:51:22: error: 'include' undeclared (first use in this function)
   51 |   inorder(u->right);#include<stdio.h>
      |                      ^~~~~~~
main.c:51:22: note: each undeclared identifier is reported only once for each function it appears in
main.c:51:30: error: 'stdio' undeclared (first use in this function); did you mean 'stdin'?
   51 |   inorder(u->right);#include<stdio.h>
      |                              ^~~~~
      |                              stdin
main.c:54:1: error: expected expression before 'typedef'
   54 | typedef struct Node{
      | ^~~~~~~
Language: C

#include<stdio.h>
#include<stdlib.h>
#define MAX 500001
#define NIL NULL
struct N{
  int key;
  struct N *parent;
  struct N *left;
  struct N *right;
};
typedef struct N * node;

void insert(int);
void ino(node);
void pr(node);
node Find(node root, int n){
  if(root == NIL || root->n == n)return n;
  if(root->n > n) return find(root->left,n);
  else return Find(root->right,n);
}
node r;

int main(){
  int i,n,x;
  char c[20];
  scanf("%d", &n);
  
  for(i = 0; i < n; i++){
    scanf("%s", c);
  
    if(c[0] == 'i'){
      scanf("%d", &x);
      insert(x);
    }
    else if(c[0] == 'f'){
      scanf ("%d" , &x);
      node t = Find(r , x);
      if(t!= NIL)printf("yes\n");
      else printf("no\n");
    }
    else if(c[0] == 'p'){
      ino(r);
      printf("\n");
      pr(r);
       printf("\n");
    }
  }
  return 0;
}

void insert(int n){
  node x = NIL;
  node y = r;
  node z;
  z = malloc(sizeof(struct N));
  z->key = n;
  z->left = NIL;
  z->right = NIL;
  while(y!=NIL){
    x = y;
    if(z->key < y->key) y = y->left;
    else y = y->right;
  }
  z->parent = x;
  if(x == NIL)r = z;
  else if( z->key < x->key) x->left = z;
  else x->right = z;
}

void ino(node a){
  if(a!=NIL){
    ino(a->left);
    printf(" %d", a->key);
    ino(a->right);
}
}

void pr(node a){
  if(a!=NIL){
    printf(" %d" , a->key);
    pr(a->left);
    pr(a->right);
  }
}

Compiler output:
main.c: In function 'Find':
main.c:17:25: error: 'struct N' has no member named 'n'
   17 |   if(root == NIL || root->n == n)return n;
      |                         ^~
main.c:17:41: error: returning 'int' from a function with return type 'node' {aka 'struct N *'} makes pointer from integer without a cast [-Wint-conversion]
   17 |   if(root == NIL || root->n == n)return n;
      |                                         ^
main.c:18:10: error: 'struct N' has no member named 'n'
   18 |   if(root->n > n) return find(root->left,n);
      |          ^~
main.c:18:26: error: implicit declaration of function 'find'; did you mean 'Find'? [-Wimplicit-function-declaration]
   18 |   if(root->n > n) return find(root->left,n);
      |                          ^~~~
      |                          Find
main.c:18:26: error: returning 'int' from a function with return type 'node' {aka 'struct N *'} makes pointer from integer without a cast [-Wint-conversion]
   18 |   if(root->n > n) return find(root->left,n);
      |                          ^~~~~~~~~~~~~~~~~~
Language: C

#include<stdio.h>
#include<stdlib.h>
 
struct node{
  struct node *r;
  struct node *l;
  struct node *parent;
  int key;
};
typedef struct node * Node;
 
Node root, NIL;
 
void insert(int);
void inorder(Node);
void preorder(Node);
Node treeSearch(Node, int);
 
int main(){
   
  int n, i, x;
  char com[10];
   
  scanf("%d", &n);
   
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
 
    if ( strcmp(com, "insert") == 0 ){
      scanf("%d", &x);
      insert(x);
    }
    else if ( strcmp(com, "print") == 0 ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if ( strcmp(com, "find") == 0 ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    }
  }
  return 0;
}
 
void insert(int k){
  int H;
  Node y = NIL;
  Node x = root;
  Node z;
   
  z = malloc(sizeof(struct 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->parent = 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->left);
  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);
}
 
Node treeSearch(Node x, int k){
  while( x != NIL && k != x->key ){
    if ( k < x->key ) x = x->l;
    else x = x->r;
  }
  return x;
}

Compiler output:
main.c: In function 'main':
main.c:29:10: error: implicit declaration of function 'strcmp' [-Wimplicit-function-declaration]
   29 |     if ( strcmp(com, "insert") == 0 ){
      |          ^~~~~~
main.c:3:1: note: include '<string.h>' or provide a declaration of 'strcmp'
    2 | #include<stdlib.h>
  +++ |+#include <string.h>
    3 | 
main.c: In function 'inorder':
main.c:83:12: error: 'struct node' has no member named 'left'
   83 |   inorder(u->left);
      |            ^~
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 treeSearch(Node x, int a){
 
  if(x == NIL || k == x->key){
    return x;
}
  if(a < x->key){
    return treeSearch(x->left, a);
}
  else{
    return treeSearch(x->right, a);
}
 
}
 
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 to be deleted
  Node x; // child of y

  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=z->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 x){
 
  if(x!=NIL){
    inorder(x->left);
    printf(" %d", x->key);
    inorder(x->right);
  }
 
 
}
void preorder(Node x){
 
  if(x!=NIL){
    printf(" %d", x->key);
    preorder(x->left);
    preorder(x->right);
  }
 
}
 
 
int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  root=NIL;
 
  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:
main.c: In function 'treeSearch':
main.c:27:18: error: 'k' undeclared (first use in this function)
   27 |   if(x == NIL || k == x->key){
      |                  ^
main.c:27:18: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include <stdio.h>
#define MAX 500000
 
int root = -1;
int key[MAX];
int left[MAX];
int right[MAX];
int k[MAX];
 
void insert(int n){
  int a = -1;
  int b = root;
  while(b!=-1){
    a = b;
    if(key[n]<key[b]){
      b = left[b];
    }
    else{
 b = right[b];
}
  }
 
  p[n] = a;
  if(a==-1){
 root = n;
}
  else if(key[z]<key[a]){
 left[a] = n;
}
  else{
 right[a] = n;
}
}
 
void preorder(int n){
  if(n == -1) return;
  printf(" %d",key[n]);
  preorder(left[n]);
  preorder(right[n]);
}
 
void inorder(int n){
  if(n == -1){
 return;
}
  inorder(left[n]);
  printf(" %d",key[n]);
  inorder(right[n]);
}
 
void print(){
  inorder(root);
  printf("\n");
  preorder(root);
  printf("\n");
}
 
int find(int n){
  int i = 0,b = root;
  int y = -1;
  while(b!=-1){
    if(key[b] == t) return 1;
    y = b;
    if(t<key[b]) b = left[b];
    else b = right[b];
  }
  return 0;
}
 
int main(){
  int i,n,x;
  int z =0;
  char A[10];
  scanf("%d",&n);
  for(i=0;i<MAX;i++){
    key[i] = -1;
    left[i] = -1;
    right[i] = -1;
    p[i] = -1;
  }
 
  for(i=0;i<n;i++){
    scanf("%s",A);
    if(A[0]=='i'){
      scanf("%d",&x);
      key[z] = x;
      insert(z);
      z++;
    }
    else if(A[0]=='p'){
 print();
}
    else if(A[0]== 'f'){
      scanf("%d",&x);
      if(find(x)==1){
 printf("yes\n");
}
      else{
 printf("no\n");
}
    }
  }
  return 0;
}

Compiler output:
main.c: In function 'insert':
main.c:23:3: error: 'p' undeclared (first use in this function)
   23 |   p[n] = a;
      |   ^
main.c:23:3: note: each undeclared identifier is reported only once for each function it appears in
main.c:27:15: error: 'z' undeclared (first use in this function)
   27 |   else if(key[z]<key[a]){
      |               ^
main.c: In function 'find':
main.c:62:18: error: 't' undeclared (first use in this function)
   62 |     if(key[b] == t) return 1;
      |                  ^
main.c: In function 'main':
main.c:79:5: error: 'p' undeclared (first use in this function)
   79 |     p[i] = -1;
      |     ^
Language: C

#include<stdio.h>
#include<stdlib.h>
#define N 10000
#define NIL NULL
struct node{
  struct node *left;
  struct node *right;
  struct node *parent;
  int key;
};
 
typedef struct node * Node;
Node root;
 
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){
    inorder(u->left);
    printf(" ");
    printf("%d",u->key);
    inorder(u->right);
  }
  
}
void preorder(Node u){ 
    if (u != NIL) {
      printf(" ");
      printf("%d",u->key); 
      preorder(u->left);
      preorder(u->right);
     
    }
}
Node IterativeTreeSearch(Node x,int k){
  if(x == NIL || k == x -> key) return x;
  if(k < x -> key) return IterativeTreeSearch(x -> left, k);
  else return IterativeTreeSearch(x -> right, k);
 
  
}
 
int main(){
  int i,n1,n2,n3;
  char str[10];
  scanf("%d",&n1);
  for(i=0;i<n1;i++){
    scanf("%s",str);
    if(str[0]=='f'){
      scanf("%d", &n2);
      Node t = IterativeTreeSearch(root, n2);
      if ( t != NIL ){ 
    printf("yes\n");
      }
      else {
    printf("no\n");
      }
    }
    else if(str[0]=='i'){  
      scanf("%d",&n3);
      insert(n);
    }
     
    else if(str[0]=='p'){
       
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
return 0;
}

Compiler output:
main.c: In function 'main':
main.c:87:14: error: 'n' undeclared (first use in this function); did you mean 'n3'?
   87 |       insert(n);
      |              ^
      |              n3
main.c:87:14: note: each undeclared identifier is reported only once for each function it appears in
Language: C

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

#define NIL -1
#define TRUE 1
#define FALSE 0
#define MAX 500000

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

void insert(int);
int find(int, int);
void inorder(int);
void preorder(int);

int root=-1;
node T[MAX];

int main(){
  int n, num,  i;
  char command[10];

  scanf("%d", &n);

  for( i=0 ; i<n ; i++ ){
    T[i].parent = NIL;
    T[i].left = NIL;
    T[i].right = NIL;
  }
    
  for( i=0 ; i<n ; i++ ){
    scanf("%s",command);
    
    if(strcmp(command, "insert") == 0){
      scanf("%d",&T[i].key);
      insert(i);
    }
    else if(strcmp(command, "find") == 0){
      scanf("%d",&num);
      if(find(num) == TRUE) printf("yes\n");
      else printf("no\n");
    }
    else if(strcmp(command, "print") == 0){
      inorder(0);
      printf("\n");
      preorder(0);
      printf("\n");
    }
  }

  return 0;
}

void insert(int z){
  int x = root;
  int y = NIL;
  
  while(x != NIL){
    y = x;
    
    if(T[z].key < T[x].key){
      x = T[x].left;
    }
    else{
      x = T[x].right;
    }
  }
  T[z].parent = y;

  //T???????????´???
  if(y == NIL){
    root = z;
  }
  else if(T[z].key < T[y].key){
    T[y].left = z;
  }
  else{
    T[y].right = z;
  }
}

int find(int x, int key){
  if(T[x].key = key) return TRUE;
  if( key<T[x].key && T[x].left!=NIL ){
    return find(T[x].left, key);
  }
  if( key>T[x].right && T[x].right!=NIL ){
    return find(T[x].right, key);
  }
  return FALSE;
}

}
void inorder(int x){
  if(x != NIL){
    inorder(T[x].left);
    printf(" %d", T[x].key);
    inorder(T[x].right);
  }
}

void preorder(int x){
  if(x != NIL){
    printf(" %d", T[x].key);
    preorder(T[x].left);
    preorder(T[x].right);
  }
}

Compiler output:
main.c: In function 'main':
main.c:46:10: error: too few arguments to function 'find'
   46 |       if(find(num) == TRUE) printf("yes\n");
      |          ^~~~
main.c:18:5: note: declared here
   18 | int find(int, int);
      |     ^~~~
main.c: At top level:
main.c:99:1: error: expected identifier or '(' before '}' token
   99 | }
      | ^
Language: C

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define cmdMax 10

typedef struct node *link;
struct node{
	int key;
	link left,right;
};

link insert(link head,link z){
	link y=NULL;
	link x=head;
	
	while(x!=NULL){
		y=x;
		if(z->key < x->key)x=x->left;
		else x=x->right;
	}
	
	if(y==NULL)head=z;
	else if(z->key < y->key)y->left=z;
	else y->right=z;
	return head;
}

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

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

int find(link u,int key){
	if(u==NULL)return 0;
	if(u->key==key)return 1;
	if(u->key>key)return find(u->left,key)
	return find(u->right,key);
}

int main(void){
	int m,i,key;
	char cmd[cmdMax];
	link head=NULL,z;
	scanf("%d",&m);
	for(i=0;i<m;i++){
		scanf("%s",cmd);
		if(!strcmp(cmd,"insert")){
			scanf("%d",&key);
			z = malloc(sizeof(*z));
			z->key=key;z->left=NULL;z->right=NULL;
			head=insert(head,z);
		}else if(!strcmp(cmd,"print")){
			inorder(head);
			printf("\n");
			preorder(head);
			printf("\n");
		}else if(!strcmp(cmd,"find")){
			scanf("%d",&key);
			if(find(head,key)!=0)printf("yes\n");
			else  printf("no\n");
		}
	}
	return 0;
}

Compiler output:
main.c: In function 'find':
main.c:45:47: error: expected ';' before 'return'
   45 |         if(u->key>key)return find(u->left,key)
      |                                               ^
      |                                               ;
   46 |         return find(u->right,key);
      |         ~~~~~~
Language: C

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

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

typedef node * Node;

#define NIL NULL


Node root;
 
Node treeMinimum (Node x ){
 
}
 
Node treeSearch (Node u, int k ){
    if (u == NIL || u->key == k ) return u;
    else
    if (u->key < k ){
        return treeSearch (u->right, k );
    }else{
        return treeSearch (u->left, k );
    } // end if 
}
 
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;
 
    if (x == NIL ){
        root = z;
    }else{
        do{
            if (x->key < k ){
                y = x->right;
            }else{
                y = x->left;
            } // end if
 
            if (y != NIL ){
                y->parent = x;
            }else{
                if (x->key < k )
                    x->right = z;
                else
                    x->left = z;
            } // end if
            x = y;
        }while (x != NIL ); // end while
    } // end if
}
 
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];
 
    root = NIL;
    scanf ("%d", &n );
    for (i = 0; i < n; i++ ){
        scanf ("%s", com );
        if (com[0] == 'i' ){    // case insert 
            scanf ("%d", &x );
            insert (x );
        }else
        if (com[0] == 'p' ){ // case print
            inorder (root );
            printf ("\n" );
            preorder (root );
            printf ("\n" );
        }else
        if (com[0] == 'f' ){    // case find
            scanf ("%d", &x );
            Node t = treeSearch (root, x );
            if ( t != NIL ) printf ("yes\n" );
            else printf ("no\n" );
        } // end if
    } // end for
 
    return 0;
}


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

#include <stdio.h>
#include <stdlib.h>
 
struct node {
  struct node *ri;
  int key;
  struct node *le;
};
typedef struct node * NodePointer;
 
NodePointer head, tail;
 
void init(void){
  head=makenode(-1);
  tail=makenode(-1);
  head->ri=tail;
  head->le=tail;
}
 
NodePointer makenode(int k){
  NodePointer x;
 
  x=malloc(sizeof(struct node));
  x->key = k;
  x->le = x->ri = tail;
 
  return x;
}
 
void insert(int k, NodePointer p){
  if(k < p->key){
    if(p->le == tail){
      p->le = makenode(k);
    }else{
      insert(k , p->le);
    }
  }else{
    if(p->ri == tail){
      p->ri = makenode(k);
    }else{
      insert(k , p->ri);
    }
  }
}
 
void preorder(NodePointer node){
  if(node != tail){
    printf(" %d", node->key);
    preorder(node->le);
    preorder(node->ri);
  }
}
 
void inorder(NodePointer node){
  if(node != tail){
    inorder(node->le);
    printf(" %d", node->key);
    inorder(node->ri);
  }
}
 
int find(int k,NodePointer node){
  if(node == tail){
    return 0;
  }
 
  if(node->key == k){
    return 1;
  }else if(node->key < k){
    return find(k , node->ri);
  }else{
    return find(k , node->le);
  }
}

int main(int argc, char *argv[]){
  char string[7];
  int n,m;
 
  init();

  scanf("%d" ,&n);
  while(n--){
    scanf("%s" ,string);
 
    if(str[0] == 'i'){ 
      scanf("%d" ,&m);
      insert(m, head);
    }else if(str[0] == 'p'){
      inorder(head->ri);
      printf("\n");
      preorder(head->ri);
      printf("\n");
    }else{
      scanf("%d" ,&m);
      if(find(m,head->ri)){
    printf("yes\n");
      }else{
    printf("no\n");
      }
    }
  }
 
  return 0;
}
 

Compiler output:
main.c: In function 'init':
main.c:14:8: error: implicit declaration of function 'makenode' [-Wimplicit-function-declaration]
   14 |   head=makenode(-1);
      |        ^~~~~~~~
main.c:14:7: error: assignment to 'NodePointer' {aka 'struct node *'} from 'int' makes pointer from integer without a cast [-Wint-conversion]
   14 |   head=makenode(-1);
      |       ^
main.c:15:7: error: assignment to 'NodePointer' {aka 'struct node *'} from 'int' makes pointer from integer without a cast [-Wint-conversion]
   15 |   tail=makenode(-1);
      |       ^
main.c: At top level:
main.c:20:13: error: conflicting types for 'makenode'; have 'struct node *(int)'
   20 | NodePointer makenode(int k){
      |             ^~~~~~~~
main.c:14:8: note: previous implicit declaration of 'makenode' with type 'int()'
   14 |   head=makenode(-1);
      |        ^~~~~~~~
main.c: In function 'main':
main.c:86:8: error: 'str' undeclared (first use in this function)
   86 |     if(str[0] == 'i'){
      |        ^~~
main.c:86:8: note: each undeclared identifier is reported only once for each function it appears in
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 jug;


Node treeSearch(Node u, int k){
  if(u->key == k){
    jug = u;
  }
  if(u->left != NIL && jug = NIL)treeSearch(u->left,k);
  if(u->right != NIL && jug = NIL) treeSearch(u->right,k);
  return jug;
}

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->left != NIL){
    inorder(u->left);
  }
  printf(" %d",u->key);
  if(u->right != NIL){
    inorder(u->right);
  }

}
void preorder(Node u){
  printf(" %d",u->key);
  if(u->left!= NIL){
    preorder(u->left);
  }
  if(u->right!= NIL){
    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);
      jug = NIL;
      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:
main.c: In function 'treeSearch':
main.c:21:28: error: lvalue required as left operand of assignment
   21 |   if(u->left != NIL && jug = NIL)treeSearch(u->left,k);
      |                            ^
main.c:22:29: error: lvalue required as left operand of assignment
   22 |   if(u->right != NIL && jug = NIL) treeSearch(u->right,k);
      |                             ^
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 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 to be deleted
  Node x; // child of y
  /* 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;
  }
  
  return;
}

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

}
void preorder(Node u){
printf(" %d",u->key);
if(u->left!=NIL) preorder(u->left);
if(u->right!=NIL)  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:
main.c:148:3: error: expected identifier or '(' before 'return'
  148 |   return 0;
      |   ^~~~~~
main.c:149:1: error: expected identifier or '(' before '}' token
  149 | }
      | ^
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 treeSearch(Node u, int k){
  while(u != NIL && k != u->key){
      if(k < u->key){
	u = u->left;
	return u;
      }else{ 
	u = u->right;
	return u;
      }
    }
}

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

 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){
     inorder(u->left);
     printf(" %d",u->key);
     inorder(u->right);
   }
}

void preorder(Node u){
 if(u != NIL){   
      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:
main.c: In function 'treeDelete':
main.c:35:9: error: implicit declaration of function 'treeSuccessor' [-Wimplicit-function-declaration]
   35 |     y = treeSuccessor(z);
      |         ^~~~~~~~~~~~~
main.c:35:7: error: assignment to 'Node' {aka 'struct node *'} from 'int' makes pointer from integer without a cast [-Wint-conversion]
   35 |     y = treeSuccessor(z);
      |       ^
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 treeSearch(Node u, int k){
  while(u != NIL && k != u->key){
      if(k < u->key){
	u = u->left;
	return u;
      }else{ 
	u = u->right;
	return u;
      }
    }
}

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;

  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){
     inorder(u->left);
     printf(" %d",u->key);
     inorder(u->right);
   }
}

void preorder(Node u){
 if(u != NIL){   
      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:
main.c: In function 'main':
main.c:102:3: error: expected declaration or statement at end of input
  102 |   return 0;
      |   ^~~~~~
Language: C++

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

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

Node *root, *NIL;

Node * find(Node *u, int k) {
  while ( u != NIL && k != u->key ) {
    if ( k < u-> key ) u = u->left;
    else u = u->right;
  }
  return u;
}

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[0] == 'f' ) {
      scanf("%d", &x);
      Node *t = find(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com == "insert" ) {
      scanf("%d", &x);
      insert(x);
    } else if ( com == "print" ) {
      inorder(root);
      printf("\n");
      preorer(root);
      printf("\n");
    }
  }

  return 0;
}

      



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

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

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


Node *root, *NIL;

Node * find(Node *u,int k){
  while(u!=NIL && k!=u->key){
    if(k<u->key) u=u->left;
    else u = u->right;
  }
  return u;
}

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;
    }
  }
}

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

  scanf("%d",&n);

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

    if(com[0] == 'f'){
      scanf("%d",&x);
      Node *t = find(root,x);
      if(t != NIL) printf("yes\n");
      else print("no\n");
    }else if(com == "insert"){
      scanf("%d",&x);
      insert(x);
    }else if(com == "print"){
      inorder(root);
      printf("\n");
      preorder(root);
      pintf("\n");
    }
  }
  return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:66:12: error: 'print' was not declared in this scope; did you mean 'printf'?
   66 |       else print("no\n");
      |            ^~~~~
      |            printf
a.cc:71:7: error: 'inorder' was not declared in this scope
   71 |       inorder(root);
      |       ^~~~~~~
a.cc:73:7: error: 'preorder' was not declared in this scope
   73 |       preorder(root);
      |       ^~~~~~~~
a.cc:74:7: error: 'pintf' was not declared in this scope; did you mean 'printf'?
   74 |       pintf("\n");
      |       ^~~~~
      |       printf
Language: C++

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

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


Node *root, *NIL;

Node * find(Node *u,int k){
  while(u!=NIL && k!=u->key){
    if(k<u->key) u=u->left;
    else u = u->right;
  }
  return u;
}

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;
    }
  }
}

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

  scanf("%d",&n);

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

    if(com[0] == 'f'){
      scanf("%d",&x);
      Node *t = find(root,x);
      if(t != NIL) printf("yes\n");
      else print("no\n");
    }else 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:66:12: error: 'print' was not declared in this scope; did you mean 'printf'?
   66 |       else print("no\n");
      |            ^~~~~
      |            printf
a.cc:71:7: error: 'inorder' was not declared in this scope
   71 |       inorder(root);
      |       ^~~~~~~
a.cc:73:7: error: 'preorder' was not declared in this scope
   73 |       preorder(root);
      |       ^~~~~~~~
Language: C++

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

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


Node *root, *NIL;

Node * find(Node *u,int k){
  while(u!=NIL && k!=u->key){
    if(k<u->key) u=u->left;
    else u = u->right;
  }
  return u;
}

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;
    }
  }
}

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

  scanf("%d",&n);

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

    if(com[0] == 'f'){
      scanf("%d",&x);
      Node *t = find(root,x);
      if(t != NIL) printf("yes\n");
      else printf("no\n");
    }else 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:71:7: error: 'inorder' was not declared in this scope
   71 |       inorder(root);
      |       ^~~~~~~
a.cc:73:7: error: 'preorder' was not declared in this scope
   73 |       preorder(root);
      |       ^~~~~~~~
Language: C++

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

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

Node *root,*NIL;

Node * find(Node *u, int k){
  while(u!=NIL&&k!=u->key){
    if(k<u->key) u=u->left;
    else u=u->right;
  }
  return u;
}

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[0]=='f'){
      scanf("%d",&x);
      Node *t=find(root,x);
      if(t!=NIL) printf("yes\n");
      elseprintf("no\n");
    }
    else 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:79:7: error: 'elseprintf' was not declared in this scope; did you mean 'vswprintf'?
   79 |       elseprintf("no\n");
      |       ^~~~~~~~~~
      |       vswprintf
Language: C++

#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<iostream>
using namespace atd;

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

};
typedef struct Node * Node;

Node *root, *NIL;

Node * find(Node *u, int k){
  while(u != NIL && k != u->key){
    if(k < u->key) u = u->l;
    else u = u->r;
  }
  return u;
}

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;
  char com[20];

  scanf("%d", &n);

  for(i = 0 ; i < n ; i++){
    scanf("%s", com);
    if(com[0] == 'f'){
      scanf("%d", &x);
      Node *t = find(root, x);
      if(t != NIL) printf("yes\n");
      else printf("no\n");
    }
    else 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:5:17: error: 'atd' is not a namespace-name
    5 | using namespace atd;
      |                 ^~~
a.cc:12:23: error: conflicting declaration 'typedef struct Node* Node'
   12 | typedef struct Node * Node;
      |                       ^~~~
a.cc:7:8: note: previous declaration as 'struct Node'
    7 | struct Node{
      |        ^~~~
a.cc: In function 'void preorder(Node*)':
a.cc:66:3: error: 'preoder' was not declared in this scope; did you mean 'preorder'?
   66 |   preoder(u->l);
      |   ^~~~~~~
      |   preorder