Language: C++

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

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

Node *root, *NIL;

Node *treeMinimum(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: In function 'Node* treeSuccessor(Node*)':
a.cc:28:43: error: expected ';' before ':' token
   28 |   if(x->r != NIL) return treeMinimum(x->r):
      |                                           ^
      |                                           ;
a.cc:28:43: error: expected primary-expression before ':' token
a.cc:30:9: error: 'y' was not declared in this scope
   30 |   while(y != NIL && x = y->r){
      |         ^
a.cc:34:10: error: 'y' was not declared in this scope
   34 |   return y;
      |          ^
a.cc: At global scope:
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 inorder(Node*)':
a.cc:108:3: error: 'preoder' was not declared in this scope
  108 |   preoder(u->l);
      |   ^~~~~~~
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