我一直试图让这个代码编译,但它似乎并不希望分区功能工作。显然这与数组有关,但我无法弄清楚它是什么。快速排序分区不编译
编辑:我使用std ::分区,而不是原始分区函数。
#include <ctime>
#include <string>
#include <algorithm>
#include <array>
#include <iostream>
using namespace std;
const int MAX_SIZE = 10000;
const int MIN_SIZE = 10;
这里的快速排序:
//quick sort
void quickSort(int arr[], int first, int last, int size)
{
if(last - first + 1< MIN_SIZE)
{
insertionSort(arr,size);
}
else
{
int pivotIndex = partition(arr, first, last);
quickSort(arr, first, pivotIndex-1,size);
quickSort(arr, pivotIndex+1,last,size);
}
}
这里的错误:
error: no matching function for call to 'partition(int*&, int&, int&)'
由于任何人谁可以清除这件事。除了分区功能以外的所有东西似乎都能正常工作。
编译器错误不是关于数组。这是关于'分区'功能本身。它甚至没有被调用,它只是编译器不能理解你试图调用的函数。 – iehrlich