项目场景:
提示:这里简述项目相关背景:
写了一个while循环, 里面用到了break, 但是报了错误说是break不可用???
问题描述
提示:这里描述项目中遇到的问题:
这里就很离谱了, 为啥呢? 在一个while循环里为啥不能用break了呢?
void AdJustDown(int* arr, int parent, int n)
{
assert(arr);
int child = parent * 2 + 1;
while (child < n);
{
if (child + 1 < n && arr[child] < arr[child + 1])
{
child = child + 1;
}
if (arr[child] > arr[parent])
{
swap(&arr[child], &arr[parent]);
parent = child;
child = 2 * parent + 1;
}
else
{
break;
}
}
}
原因分析:
提示:这里填写问题的分析:
解决方案:
提示:这里填写该问题的具体解决方案:
略.
EOF