Language: C++

#include<iostream>
using namespace std;
#define MAX 500000
#define data 2000000000

int LEFT[MAX/2+2],RIGHT[MAX/2+2];
int count;

void merge(intA[],int n,int left,int mid,int right){
	int n1=mid-left;
	int n2=right-mid;
	
	for(i=0; i<n1; i++){
		LEFT[i]=A[left+i];
	}
	for(i=0; i<n2; i++){
		RIGHT[i]=A[mid+i];
	}
	
	LEFT[n1]=RIGHT[n2]=data;
	int i=0;j=0;//新たにカウント用変数を宣言する
	int k;
	for(k=left; k<right; k++){
		count++;
		if(LEFT[i]<=RIGHT[j]){
			A[k]=LEFT[i++];
		}
		
		else{
			A[k]=RIGHT[j++];
		}
	}
}

void mergesort(int A[],int n,int left,int right){
	if(left+1<right){
		int mid=((left+right)/2);
		mergesort(A,n,left,mid);
		mergesort(A,n,mid,right);
		merge(A,n,left,mid,right);
	}
}

int main(){
	int A[MAX},n,i;
	count=0;
	
	cin>>n;
	for(i=0; i<n; i++)
	cin>>A[i];
	
	mergesort(A,n,0,n);
	
	for(i=0; i<n; i++){
		if(i) cout<<" ";//iが非ゼロであれば空白を、そうでなければA[i]をcoutする。
		cout<<A[i];
	}
	cout<<endl;
	
	cout<<cnt<<endl;
	
	return 0;
	}


Compiler output:
a.cc:9:6: error: variable or field 'merge' declared void
    9 | void merge(intA[],int n,int left,int mid,int right){
      |      ^~~~~
a.cc:9:12: error: 'intA' was not declared in this scope; did you mean 'int'?
    9 | void merge(intA[],int n,int left,int mid,int right){
      |            ^~~~
      |            int
a.cc:9:17: error: expected primary-expression before ']' token
    9 | void merge(intA[],int n,int left,int mid,int right){
      |                 ^
a.cc:9:19: error: expected primary-expression before 'int'
    9 | void merge(intA[],int n,int left,int mid,int right){
      |                   ^~~
a.cc:9:25: error: expected primary-expression before 'int'
    9 | void merge(intA[],int n,int left,int mid,int right){
      |                         ^~~
a.cc:9:34: error: expected primary-expression before 'int'
    9 | void merge(intA[],int n,int left,int mid,int right){
      |                                  ^~~
a.cc:9:42: error: expected primary-expression before 'int'
    9 | void merge(intA[],int n,int left,int mid,int right){
      |                                          ^~~
a.cc: In function 'void mergesort(int*, int, int, int)':
a.cc:40:17: error: 'merge' was not declared in this scope
   40 |                 merge(A,n,left,mid,right);
      |                 ^~~~~
a.cc: In function 'int main()':
a.cc:45:18: error: expected ']' before '}' token
   45 |         int A[MAX},n,i;
      |                  ^
a.cc: At global scope:
a.cc:45:19: error: mixing declarations and function-definitions is forbidden
   45 |         int A[MAX},n,i;
      |                   ^
a.cc:46:9: error: 'count' does not name a type
   46 |         count=0;
      |         ^~~~~
a.cc:48:9: error: 'cin' does not name a type
   48 |         cin>>n;
      |         ^~~
a.cc:49:9: error: expected unqualified-id before 'for'
   49 |         for(i=0; i<n; i++)
      |         ^~~
a.cc:49:18: error: 'i' does not name a type
   49 |         for(i=0; i<n; i++)
      |                  ^
a.cc:49:23: error: 'i' does not name a type
   49 |         for(i=0; i<n; i++)
      |                       ^
a.cc:52:18: error: expected constructor, destructor, or type conversion before '(' token
   52 |         mergesort(A,n,0,n);
      |                  ^
a.cc:54:9: error: expected unqualified-id before 'for'
   54 |         for(i=0; i<n; i++){
      |         ^~~
a.cc:54:18: error: 'i' does not name a type
   54 |         for(i=0; i<n; i++){
      |                  ^
a.cc:54:23: error: 'i' does not name a type
   54 |         for(i=0; i<n; i++){
      |                       ^
a.cc:58:9: error: 'cout' does not name a type
   58 |         cout<<endl;
      |         ^~~~
a.cc:60:9: error: 'cout' does not name a type
   60 |         cout<<cnt<<endl;
      |         ^~~~
a.cc:62:9: error: expected unqualified-id before 'return'
   62 |         return 0;
      |         ^~~~~~
a.cc:63:9: error: expected declaration before '}' token
   63 |         }
      |         ^