int binarySearch(int *data, int low, int high, int find)
{
while (low <= high)
{
int mid = (low + high) / 2;
if (data[mid] == find)
return mid;
else if (data[mid] > find)
high = mid - 1;
else
low = mid + 1;
}
return -1;
}
#include <stdio.h>
void quickSort(int* p,int low,int high)
{
if(low<high)
{
int pivot = p[low];
int l = low;
int h = high;
while (l<h)
{
while (p[h]>=pivot&&l<h)
{
h--;
}
p[l] = p[h];
while (p[l]<=pivot&&l<h)
{
l++;
}
p[h] = p[l];
}
p[l] = pivot;
quickSort(p,low,l-1);
quickSort(p,l+1,high);
}
}
int main(void)
{
int arr[10] = {6,5,4,3,2,1,7,8,9,0};
quickSort(arr,0,9);
for(int i=0; i<10; i++)
{
printf("%d\n",arr[i]);
}
return 0;
}