Skip to content

Commit 1d8d6f8

Browse files
authored
Merge pull request #19 from mersonfufu/master
Create QuickSort-C.c
2 parents b704cfc + 7d749ed commit 1d8d6f8

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

QuickSort-C.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
void quickSort(int *vetor, int inicio, int fim){
2+
int i = inicio, f = fim, pivot = vetor[(inicio + fim) / 2], aux;
3+
do {
4+
while(vetor[i] < pivot)
5+
i++;
6+
while(vetor[f] > pivot)
7+
f--;
8+
if(i <= f){
9+
aux = vetor[i];
10+
vetor[i++] = vetor[f];
11+
vetor[f--] = aux;
12+
}
13+
} while(i < f);
14+
if(inicio < f)
15+
quickSort(vetor, inicio, f);
16+
if(i < fim)
17+
quickSort(vetor, i, fim);
18+
}

0 commit comments

Comments
 (0)