Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void qsort(int array[], int start, int end){
- int temp_start = start, temp_end = end;
- int part = array[start];
- if(start >= end){
- return;
- }
- while(temp_end > temp_start){
- for(temp_end; array[temp_end] >= array[temp_start] && temp_end > temp_start; temp_end --);
- array[temp_start] = array[temp_end];
- for(temp_start; array[temp_start] < part && temp_end > temp_start; temp_start++);
- array[temp_end] = array[temp_start];
- }
- array[temp_start] = part;
- qsort(array, start, temp_start);
- qsort(array, temp_start, end);
- }
- #define MAX 7
- #define START_POS 0
- #define END_POS (MAX - 1)
- void qsort(int array[], int start, int end);
- void show(int array[], int size);
- void random_input(int array[], int size);
- int main(){
- int array[MAX];
- random_input(array, MAX);
- show(array, MAX);
- qsort(array, START_POS, END_POS);
- show(array, MAX);
- return 0;
- }
- 7 8
- 7
- qsort(array, temp_start, end)
- 7 8
- 7
- 7 8
- qsort(array, temp_start + 1, end);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement