Language: C++

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

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

Node *root, *NIL;

Node *treeMininum(Node *x){
  while(x->l != NIL) x = x->l;
  return x;
}

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

Node *treeSuccessor(Node *x){
  if(x->r != NIL) return treeMinimum(x->r):
  Node *y = x->p;
  while(y != NIL && x = y->r){
    x = y;
    y = y->p;
  }
  return y;
}

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

  if(z->l == NIL || z->r == NIL) y = z;
  else y = treeSuccessor(z);

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

  if(x != NIL){
    x->p = y->p;
  }

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

if(y != z){
  z->key = y->key;
 }
free(y);
}

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

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[0] == 'f'){
      sacnf("%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");
    }
    else if(com == "delete"){
      scanf("%d", &x);
      treeDelete(find(root, x));
    }
  }
  return 0;
}


Compiler output:
a.cc:12:1: error: 'Node' does not name a type
   12 | Node *root, *NIL;
      | ^~~~
a.cc:14:1: error: 'Node' does not name a type
   14 | Node *treeMininum(Node *x){
      | ^~~~
a.cc:19:1: error: 'Node' does not name a type
   19 | Node * find(Node *u, int k){
      | ^~~~
a.cc:27:1: error: 'Node' does not name a type
   27 | Node *treeSuccessor(Node *x){
      | ^~~~
a.cc:37:6: error: variable or field 'treeDelete' declared void
   37 | void treeDelete(Node *z){
      |      ^~~~~~~~~~
a.cc:37:23: error: 'z' was not declared in this scope
   37 | void treeDelete(Node *z){
      |                       ^
a.cc:67:1: error: expected unqualified-id before 'if'
   67 | if(y != z){
      | ^~
a.cc:70:5: error: expected constructor, destructor, or type conversion before '(' token
   70 | free(y);
      |     ^
a.cc:71:1: error: expected declaration before '}' token
   71 | }
      | ^
a.cc: In function 'void insert(int)':
a.cc:74:9: error: 'x' was not declared in this scope
   74 |   Node *x = root,*y = NIL, *z;
      |         ^
a.cc:74:13: error: 'root' was not declared in this scope
   74 |   Node *x = root,*y = NIL, *z;
      |             ^~~~
a.cc:74:19: error: 'y' was not declared in this scope
   74 |   Node *x = root,*y = NIL, *z;
      |                   ^
a.cc:74:23: error: 'NIL' was not declared in this scope
   74 |   Node *x = root,*y = NIL, *z;
      |                       ^~~
a.cc:74:29: error: 'z' was not declared in this scope
   74 |   Node *x = root,*y = NIL, *z;
      |                             ^
a.cc:76:14: error: expected primary-expression before ')' token
   76 |   z = (Node *)malloc(sizeof(Node));
      |              ^
a.cc: At global scope:
a.cc:105:6: error: variable or field 'inorder' declared void
  105 | void inorder(Node *u){
      |      ^~~~~~~
a.cc:105:20: error: 'u' was not declared in this scope
  105 | void inorder(Node *u){
      |                    ^
a.cc:112:6: error: variable or field 'preorder' declared void
  112 | void preorder(Node *u){
      |      ^~~~~~~~
a.cc:112:21: error: 'u' was not declared in this scope
  112 | void preorder(Node *u){
      |                     ^
a.cc: In function 'int main()':
a.cc:129:7: error: 'sacnf' was not declared in this scope; did you mean 'scanf'?
  129 |       sacnf("%d", &x);
      |       ^~~~~
      |       scanf
a.cc:130:13: error: 't' was not declared in this scope
  130 |       Node *t = find(root, x);
      |             ^
a.cc:130:22: error: 'root' was not declared in this scope
  130 |       Node *t = find(root, x);
      |                      ^~~~
a.cc:131:15: error: 'NIL' was not declared in this scope
  131 |       if(t != NIL) printf("yes\n");
      |               ^~~
a.cc:139:15: error: 'root' was not declared in this scope
  139 |       inorder(root);
      |               ^~~~
a.cc:139:7: error: 'inorder' was not declared in this scope
  139 |       inorder(root);
      |       ^~~~~~~
a.cc:141:7: error: 'preorder' was not declared in this scope
  141 |       preorder(root);
      |       ^~~~~~~~
a.cc:146:23: error: 'root' was not declared in this scope
  146 |       treeDelete(find(root, x));
      |                       ^~~~
a.cc:146:7: error: 'treeDelete' was not declared in this scope; did you mean 'timer_delete'?
  146 |       treeDelete(find(root, x));
      |       ^~~~~~~~~~
      |       timer_delete