Language: C++

#include <iostream>
using namespace std;
void merge(int* a, int low, int mid, int high, int& cmpr) {
??????int lSize = mid - low;
??????int rSize = high - mid;
??????int lIndex = 0;
??????int rIndex = 0;
??????int b[lSize + rSize];
??????int cur = 0;
??????while(lIndex < lSize && rIndex < rSize) {
??????????????cmpr++;
??????????????if (a[lIndex] <= a[rIndex]) {
????????????????????b[cur++] = a[lIndex++];
??????????????}
??????????????else {
????????????????????b[cur++] = a[rIndex++];
??????????????}
??????}
??????while(lIndex < lSize) {
??????????????b[cur++] = a[lIndex++];
??????}
??????while(rIndex < rSize) {
??????????????b[cur++] = a[rIndex++];
??????}
??????for (int i = low; i < high; i ++) {
??????????????a[i] = b[i - low];
??????}
????????????
}
void mergeSort(int*a, int low, int high, int& cmpr) {
??????if (low + 1 >= high) {
????????????return;
??????}
??????int mid = (low + high) / 2;
??????mergeSort(a, low, mid, cmpr);
??????mergeSort(a, mid, high, cmpr);
??????merge(a, low, mid, high, cmpr);
}
int main() {
??????int n;
??????cin >> n;
??????int a[n];
??????for (int i = 0; i < n; i ++) {
??????????????cin >> a[i];
??????}
??????int cmpr = 0;
??????mergeSort(a, 0, n, cmpr);
??????for (int i = 0; i < n; i ++) {
??????????????cout << a[i] << " ";
??????}
??????cout << endl;
??????cout << cmpr;
}

Compiler output:
a.cc: In function 'void merge(int*, int, int, int, int&)':
a.cc:4:1: error: expected primary-expression before '?' token
    4 | ??????int lSize = mid - low;
      | ^
a.cc:4:2: error: expected primary-expression before '?' token
    4 | ??????int lSize = mid - low;
      |  ^
a.cc:4:3: error: expected primary-expression before '?' token
    4 | ??????int lSize = mid - low;
      |   ^
a.cc:4:4: error: expected primary-expression before '?' token
    4 | ??????int lSize = mid - low;
      |    ^
a.cc:4:5: error: expected primary-expression before '?' token
    4 | ??????int lSize = mid - low;
      |     ^
a.cc:4:6: error: expected primary-expression before '?' token
    4 | ??????int lSize = mid - low;
      |      ^
a.cc:4:7: error: expected primary-expression before 'int'
    4 | ??????int lSize = mid - low;
      |       ^~~
a.cc:4:7: error: expected ':' before 'int'
    4 | ??????int lSize = mid - low;
      |       ^~~
      |       :
a.cc:4:7: error: expected primary-expression before 'int'
    4 | ??????int lSize = mid - low;
      |       ^~~
a.cc:4:7: error: expected ':' before 'int'
    4 | ??????int lSize = mid - low;
      |       ^~~
      |       :
a.cc:4:7: error: expected primary-expression before 'int'
    4 | ??????int lSize = mid - low;
      |       ^~~
a.cc:4:7: error: expected ':' before 'int'
    4 | ??????int lSize = mid - low;
      |       ^~~
      |       :
a.cc:4:7: error: expected primary-expression before 'int'
    4 | ??????int lSize = mid - low;
      |       ^~~
a.cc:4:7: error: expected ':' before 'int'
    4 | ??????int lSize = mid - low;
      |       ^~~
      |       :
a.cc:4:7: error: expected primary-expression before 'int'
    4 | ??????int lSize = mid - low;
      |       ^~~
a.cc:4:7: error: expected ':' before 'int'
    4 | ??????int lSize = mid - low;
      |       ^~~
      |       :
a.cc:4:7: error: expected primary-expression before 'int'
    4 | ??????int lSize = mid - low;
      |       ^~~
a.cc:4:7: error: expected ':' before 'int'
    4 | ??????int lSize = mid - low;
      |       ^~~
      |       :
a.cc:4:7: error: expected primary-expression before 'int'
    4 | ??????int lSize = mid - low;
      |       ^~~
a.cc:5:1: error: expected primary-expression before '?' token
    5 | ??????int rSize = high - mid;
      | ^
a.cc:5:2: error: expected primary-expression before '?' token
    5 | ??????int rSize = high - mid;
      |  ^
a.cc:5:3: error: expected primary-expression before '?' token
    5 | ??????int rSize = high - mid;
      |   ^
a.cc:5:4: error: expected primary-expression before '?' token
    5 | ??????int rSize = high - mid;
      |    ^
a.cc:5:5: error: expected primary-expression before '?' token
    5 | ??????int rSize = high - mid;
      |     ^
a.cc:5:6: error: expected primary-expression before '?' token
    5 | ??????int rSize = high - mid;
      |      ^
a.cc:5:7: error: expected primary-expression before 'int'
    5 | ??????int rSize = high - mid;
      |       ^~~
a.cc:5:7: error: expected ':' before 'int'
    5 | ??????int rSize = high - mid;
      |       ^~~
      |       :
a.cc:5:7: error: expected primary-expression before 'int'
    5 | ??????int rSize = high - mid;
      |       ^~~
a.cc:5:7: error: expected ':' before 'int'
    5 | ??????int rSize = high - mid;
      |       ^~~
      |       :
a.cc:5:7: error: expected primary-expression before 'int'
    5 | ??????int rSize = high - mid;
      |       ^~~
a.cc:5:7: error: expected ':' before 'int'
    5 | ??????int rSize = high - mid;
      |       ^~~
      |       :
a.cc:5:7: error: expected primary-expression before 'int'
    5 | ??????int rSize = high - mid;
      |       ^~~
a.cc:5:7: error: expected ':' before 'int'
    5 | ??????int rSize = high - mid;
      |       ^~~
      |       :
a.cc:5:7: error: expected primary-expression before 'int'
    5 | ??????int rSize = high - mid;
      |       ^~~
a.cc:5:7: error: expected ':' before 'int'
    5 | ??????int rSize = high - mid;
      |       ^~~
      |       :
a.cc:5:7: error: expected primary-expression before 'int'
    5 | ??????int rSize = high - mid;
      |       ^~~
a.cc:5:7: error: expected ':' before 'int'
    5 | ??????int rSize = high - mid;
      |       ^~~
      |       :
a.cc:5:7: error: expected primary-expression before 'int'
    5 | ??????int rSize = high - mid;
      |       ^~~
a.cc:6:1: error: expected primary-expression before '?' token
    6 | ??????int lIndex = 0;
      | ^
a.cc:6:2: error: expected primary-expression before '?' token
    6 | ??????int lIndex = 0;
      |  ^
a.cc:6:3: error: expected primary-expression before '?' token
    6 | ??????int lIndex = 0;
      |   ^
a.cc:6:4: error: expected primary-expression before '?' token
    6 | ??????int lIndex = 0;
      |    ^
a.cc:6:5: error: expected primary-expression before '?' token
    6 | ??????int lIndex = 0;
      |     ^
a.cc:6:6: error: expected primary-expression before '?' token
    6 | ??????int lIndex = 0;
      |      ^
a.cc:6:7: error: expected primary-expression before 'int'
    6 | ??????int lIndex = 0;
      |       ^~~
a.cc:6:7: error: expected ':' before 'int'
    6 | ??????int lIndex = 0;
      |       ^~~
      |       :
a.cc:6:7: error: expected primary-expression before 'int'
    6 | ??????int lIndex = 0;
      |       ^~~
a.cc:6:7: error: expected ':' before 'int'
    6 | ??????int lIndex = 0;
      |       ^~~
      |       :
a.cc:6:7: error: expected primary-expression before 'int'
    6 | ??????int lIndex = 0;
      |       ^~~
a.cc:6:7: error: expected ':' before 'int'
    6 | ??????int lIndex = 0;
      |       ^~~
      |       :
a.cc:6:7: error: expected primary-expression before 'int'
    6 | ??????int lIndex = 0;
      |       ^~~
a.cc:6:7: error: expected ':' before 'int'
    6 | ??????int lIndex = 0;
      |       ^~~
      |       :
a.cc:6:7: error: expected primary-expression before 'int'
    6 | ??????int lIndex = 0;
      |       ^~~
a.cc:6:7: error: expected ':' before 'int'
    6 | ??????int lIndex = 0;
      |       ^~~
      |       :
a.cc:6:7: error: expected primary-expression before 'int'
    6 | ??????int lIndex = 0;
      |       ^~~
a.cc:6:7: error: expected ':' before 'int'
    6 | ??????int lIndex = 0;
      |       ^~~
      |       :
a.cc:6:7: error: expected primary-expression before 'int'
    6 | ??????int lIndex = 0;
      |       ^~~
a.cc:7:1: error: expected primary-expression before '?' token
    7 | ??????int rIndex = 0;
      | ^
a.cc:7:2: error: expected primary-expression before '?' token
    7 | ??????int rIndex = 0;
      |  ^
a.cc:7:3: error: expected primary-expression before '?' token
    7 | ??????int rIndex = 0;
      |   ^
a.cc:7:4: error: expected primary-expression before '?' token
    7 | ??????int rIndex = 0;
      |    ^
a.cc:7:5: error: expected primary-expression before '?' token
    7 | ??????int rIndex = 0;
      |     ^
a.cc:7:6: error: expected primary-expression before '?' token
    7 | ??????int rIndex = 0;
      |      ^
a.cc:7:7: error: expected primary-expression before 'int'
    7 | ??????int rIndex = 0;
      |       ^~~
a.cc:7:7: error: expected ':' before 'int'
    7 | ??????int rIndex = 0;
      |       ^~~
      |       :
a.cc:7:7: error: expected primary-expression before 'int'
    7 | ??????int rIndex = 0;
      |       ^~~
a.cc:7:7: error: expected ':' before 'int'
    7 | ??????int rIndex = 0;
      |       ^~~
      |       :
a.cc:7:7: error: expected primary-expression before 'int'
    7 | ??????int rIndex = 0;
      |       ^~~
a.cc:7:7: error: expected ':' before 'int'
    7 | ??????int rIndex = 0;
      |       ^~~
      |       :
a.cc:7:7: error: expected primary-expression before 'int'
    7 | ??????int rIndex = 0;
      |       ^~~
a.cc:7:7: error: expected ':' before 'int'
    7 | ??????int rIndex = 0;
      |       ^~~
      |       :
a.cc:7:7: error: expected primary-expression before 'int'
    7 | ??????int rIndex = 0;
      |       ^~~
a.cc:7:7: error: expected ':' before 'int'
    7 | ??????int rIndex = 0;
      |       ^~~
      |       :
a.cc:7:7: error: expected primary-expression before 'int'
    7 | ??????int rIndex = 0;
      |       ^~~
a.cc:7:7: error: expected ':' before 'int'
    7 | ??????int rIndex = 0;
      |       ^~~
      |       :
a.cc:7:7: error: expected primary-expression before 'int'
    7 | ??????int rIndex = 0;
      |       ^~~
a.cc:8:1: error: expected primary-expression before '?' token
    8 | ??????int b[lSize + rSize];
      | ^
a.cc:8:2: error: expected primary-expression before '?' token
    8 | ??????int b[lSize + rSize];
      |  ^
a.cc:8:3: error: expected primary-expression before '?' token
    8 | ??????int b[lSize + rSize];
      |   ^
a.cc:8:4: error: expected primary-expression before '?' token
    8 | ??????int b[lSize + rSize];
      |    ^
a.cc:8:5: error: expected primary-expression before '?' token
    8 | ??????int b[lSize + rSize];
      |     ^
a.cc:8:6: error: expected primary-expression before '?' token
    8 | ??????int b[lSize + rSize];
      |      ^
a.cc:8:7: error: expected primary-expression before 'int'
    8 | ??????int b[lSize + rSize];
      |       ^~~
a.cc:8:7: error: expected ':' before 'int'
    8 | ??????int b[lSize + rSize];
      |       ^~~
      |       :
a.cc:8:7: error: expected primary-expression before 'int'
    8 | ??????int b[lSize + rSize];
      |       ^~~
a.cc:8:7: error: expected ':' before 'int'
    8 | ??????int b[lSize + rSize];
      |       ^~~
      |       :
a.cc:8:7: error: expected primary-expression before 'int'
    8 | ??????int b[lSize + rSize];
      |       ^~~
a.cc:8:7: error: expected ':' before 'int'
    8 | ??????int b[lSize + rSize];
      |       ^~~
      |       :
a.cc:8:7: error: expected primary-expression before 'int'
    8 | ??????int b[lSize + rSize];
      |       ^~~
a.cc:8:7: error: expected ':' before 'int'
    8 | ??????int b[lSize + rSize];
      |       ^~~
      |       :
a.cc:8:7: error: expected primary-expression before 'int'
    8 | ??????int b[lSize + rSize];
      |       ^~~
a.cc:8:7: error: expected ':' before 'int'
    8 | ??????int b[lSize + rSize];
      |       ^~~
      |       :
a.cc:8:7: error: expected primary-expression before 'int'
    8 |