1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
#include <iostream>
#include <stdlib.h>
using std::cin;
using std::cout;
int compareFunc(int, int);
int main() {
const int ARR_SIZE = 10;
int intArr[ARR_SIZE] = {87, 28, 100, 78, 84, 98, 75, 70, 81, 68};
qsort(intArr, ARR_SIZE, sizeof(int), compareFunc);
return 0;
};
// Comparator function for qsort
int compareFunc(const void * voidA, const void * voidB) {
int * intA = (int *)(voidA);
int * intB = (int *)(voidB);
return *intA - *intB;
};
|