void heap_sort (int *v, int n) { int p, m, x; for (p = n / 2; p >= 1; --p) peneira (p, n, v); for (m = n; m >= 2; --m) { x = v[1], v[1] = v[m], v[m] = x; peneira (1, m - 1, v); } }
void heapsort(int *vet, int n) { int i, tmp; for (i = (n / 2); i >= 0; i--) { peneira(vet, i, n - 1); } for (i = n-1; i >= 1; i--) { tmp = vet[0]; vet[0] = vet[i]; vet[i] = tmp; peneira(vet, 0, i-1); } }