【发布时间】:2020-04-01 03:45:03
【问题描述】:
int sort(int a[],int n)
{
int h;
int b[n];
h=n/2
//copy a[] to b[]
sort(b,n)
sort(b+h, n-h)
//merge two halves in b to a
return;
}
在该代码中,我如何理解 sort(b,h) sort(b+h,n-h) 部分。 (b+h) 是什么意思??
【问题讨论】:
-
int b[n];不是有效的 C++,因为 C++ 不允许变长数组。这只是因为编译器扩展而编译。 -
sort(b,n)应该是sort(b,h)。