请假难题目啊,20分钟内要完成的...
void func(int* numbers, int left, int right){
int pivot, l_hold, r_hold;
l_hold = left;
r_hold = right;
pivot = numbers;
while (left < right)
{
while ((numbers >= pivot) && (left < right))
right--;
if (left != right) {
numbers = numbers;
left++;
}
while ((numbers <= pivot) && (left < right))
left++;
if (left != right)
{
numbers = numbers;
right--;
}
}
numbers = pivot;
pivot = left;
left = l_hold;
right = r_hold;
if (left < pivot)
func(numbers, left, pivot-1);
if (right > pivot)
func(numbers, pivot+1, right);
}
What is this function for? If you are doing unit testing of this testing, which kind of parameters you want to pass in this function and what result you are expecting? 这道题本身就是错的,哪有看着代码测代码的,测试没有依据是没办法进行测试的。功能不是通过读代码了解的,什么都不知道,根本没法判断代码是不是错的,最多能找到一些语法错误。 似乎是一个快速排序(quick-sort)算法 似乎是从数组中选择最大值和最小值的排序,这恐怕是白盒测试审查代码的问题。
审查代码中,不断占用内存的变量,造成内存泄露。
页:
[1]