使用数组时定义无穷大?为什么?
void Merge(int *Array,int left,int mid,int right) //合并{
int *L = new int[mid -left+ 1];
int *R = new int[right - mid];
for (int i = 0; i < mid-left+1; i++)
{
L[i] = Array[left + i];
}
for (int j = 0; j < right-mid; j++)
{
R[j] = Array[mid + j + 1];
}
L[mid-left+1] = R[right-mid] = INT_MAX; //定义无穷大
int i = 0, j = 0;
for (int k = left; k <= right; k++)
{
if (L[i] < R[j])
{
Array[k] = L[i];
i++;
}
else {
Array[k] = R[j];
j++;
}
}
}
为什么要定义无穷大?