A quick sort program that I wrote using C programming language.
My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.
My mobile number here in the Philippines is 09173084360.
Please subscribe to my channel https://www.youtube.com/channel/UCOs-lpOoIeJoh6gpJthPoGg
=================================================
You can buy my C++ book online at
https://www.mindshaperspublishing.com/product/beginners-guide-to-c-programming/
You can buy my book in introduction to computer networking at
https://www.unlimitedbooksph.com/product-page/introduction-to-computer-networking
Want to support my channel?
GCash Account
Jake Pomperada
09173084360
Paypal
https://paypal.me/jakerpomperada
Patreon
https://www.patreon.com/jakerpomperada
Thank you very much for your support.
Program Listing#include <stdio.h> #include <stdlib.h> int Quick_Sort(int *items, int left, int right) { int pivot = left; int i = left +1, j = right, temp; if (left < right) { while (1) { while (items[j] > items[pivot]) j--; while (items[i] <= items[pivot]) i++; if (i < j) { temp = items[i]; items[i] = items[j]; items[j] = temp; } else break; } temp = items[pivot]; items[pivot] = items[j]; items[j] = temp; Quick_Sort(items, left, j-1); Quick_Sort(items, j+1, right); } return 0; } int main() { int a=0,num=0, *items; printf("\n"); printf("\tQuick Sort in C"); printf("\n\n"); printf("\tHow Many Items? : "); scanf("%d", &num); items = (int *)malloc(sizeof (int) * num); printf("\n\n"); for (a = 0; a < num; a++) { printf("\tEnter Value in Item No. %d : ",a+1); scanf("%d", &items[a]); } printf("\n\n"); printf("\tBefore Sorting\n"); printf("\n\n"); printf("\t"); for (a = 0; a < num; a++) printf("%5d",items[a]); printf("\n"); Quick_Sort(items, 0, num-1); printf("\n\n"); printf("\tAfter Sorting:\n"); printf("\n\n"); printf("\t"); for (a= 0; a < num; a++) printf("%5d", items[a]); printf("\n\n"); printf("\tEnd of Program"); printf("\n"); }