
Defining an Array
I am writing a mergesort algorithm program for school. The pseudocode says that I have to create an array 'L' and array 'R' with a size that is determined by calculations done with some array indices.
I could basically hardcode in some large arrays.
However, is there a way of doing the calculations and then inputing the result into the array declaration...
//example of function
MERGE(A,p,q,r)/*where A is array, p is first indice, q is lower bound midpoint, and r id last indice*/
{
n1 = q  p + 1;
n2 = r  q;
int L[n1];
int R[n2];
}

You could do something like this:
Code:
n1 = q  p + 1;
n2 = r  q;
int *L = new int [n1];
int *R = new int [n2];