Add to Favorites    Make Home Page 5090 Online  
 Language Categories  
 Our Services  

Home » C++ Home » Computer Graphics Home » Quick Sort Program with Text Graphics

A D V E R T I S E M E N T

Search Projects & Source Codes:

Title Quick Sort Program with Text Graphics
Author Rakesh Juyal
Author Email Rakesh_In_Uk [at] Yahoo.com
Description Quick Sort Program with Text Graphics.
Category C++ » Computer Graphics
Hits 375803
Code Select and Copy the Code
// Quick Sort // // By: Rakesh Juyal // // I.T.S. Mohan Nagar, Gzb // // mailme: juyalrules@yahoo.com // // mailme: rakesh@mindless.com // #include <iostream.h> #include <stdio.h> #include <dos.h> #include <conio.h> #define MAX 15 #define ValueOf( x ) ( x.value() ) #define Exchange( x , y ) ( x.exchange(y) ) class element { int _value; int _color; public: element() { _color = 15; } void get() { scanf ( "%d", &_value ); } int value (){ return _value;} void exchange ( element &e ) { element temp; temp = e; e = *this; *this = temp; } void setcolor ( int col ) { _color = col; } void show() { textbackground ( _color ); if ( _color == 15 ) { textcolor ( 0 ); } else { textcolor ( 15 ); } cprintf ( " %d " , _value ); printf ( " " ); } }; /* int element :: value () { return _value; } */ void QuickSort ( element * , int , int ); int partition ( element * , int , int ); void Display ( element *A , int p , int r ); void main() { element array[MAX]; int i = 1; textbackground ( 0 ); textcolor ( 15 ); clrscr (); printf ( " Enter %d elements:- > ", MAX - 1 ); for ( i = 1; i < MAX; i++ ) array[i].get(); printf ( " " ); for ( i = 1; i < MAX; i++ ) array[i].show(); getch(); printf ( " " ); QuickSort ( array , 1 , MAX - 1 ); printf ( " " ); for ( i = 1; i < MAX; i++ ) array[i].show(); getch(); } void QuickSort ( element *A , int p , int r ) { int q; if ( p < r ) { q = partition ( A , p , r ); QuickSort ( A , 1 , q - 1 ); QuickSort ( A , q + 1 , r ); } } int partition ( element *A , int p , int r ) { int key , i = 1 , j = 1; key = ValueOf ( A[r] ); A[r].setcolor ( RED ); i = p - 1; for ( j = p ; j <= r; j++ ) { if ( ValueOf ( A[j] ) <= key ) { i = i + 1; Exchange ( A[j] , A[i] ); } else { // A[j].setcolor ( BLUE ); } Display ( A , 1 , MAX ); delay ( 100 ); } A[i].setcolor ( GREEN ); Display ( A , 1 , MAX ); printf ( " > %d at correct position. ", ValueOf ( A[i] ) ); return i ; } void Display ( element *A , int p , int r ) { if ( wherey () > 23 ) { getch(); textbackground ( 0 ); textcolor ( 15 ); clrscr(); } printf ( " " ); for ( int i = p; i < r; i++ ) { A[i].show(); } }

Related Source Codes

Script Name Author
Moving ball screen saver karlmarx
The Classic Game of Snake & Ladder Lakshmi Narayana .A
Railway seat reservation question which comes in sapient VyomWorld
To calculate percentile Ravi Mathur
Send to folder ANIMESH SAHU
Analog clock and calendar Nazia & Rida
HIGH/LOW GAME MOLLY ARORA
Data structure (stack Implimentation) Swapnil B Adsure
Memory Game AnirudhSanyal
Easy Calc Anirudh Sanyal
GK Quiz Anirudh Sanyal
Hangman Game Manish Jain
Snakeman Manish Jain
Full month Calendar Nigi
Cursor shapes nigi

A D V E R T I S E M E N T




Google Groups Subscribe to SourceCodesWorld - Techies Talk
Email:

Free eBook - Interview Questions: Get over 1,000 Interview Questions in an eBook for free when you join JobsAssist. Just click on the button below to join JobsAssist and you will immediately receive the Free eBook with thousands of Interview Questions in an ebook when you join.

New! Click here to Add your Code!


ASP Home | C Home | C++ Home | COBOL Home | Java Home | Pascal Home
Source Codes Home Page

 Advertisements  

Google Search

Google

Source Codes World.com is a part of Vyom Network.

Vyom Network : Web Hosting | Dedicated Server | Free SMS, GRE, GMAT, MBA | Online Exams | Freshers Jobs | Software Downloads | Interview Questions | Jobs, Discussions | Placement Papers | Free eBooks | Free eBooks | Free Business Info | Interview Questions | Free Tutorials | Arabic, French, German | IAS Preparation | Jokes, Songs, Fun | Free Classifieds | Free Recipes | Free Downloads | Bangalore Info | Tech Solutions | Project Outsourcing, Web Hosting | GATE Preparation | MBA Preparation | SAP Info | Software Testing | Google Logo Maker | Freshers Jobs

Sitemap | Privacy Policy | Terms and Conditions | Important Websites
Copyright ©2003-2024 SourceCodesWorld.com, All Rights Reserved.
Page URL: http://www.sourcecodesworld.com/source/show.asp?ScriptID=823


Download Yahoo Messenger | Placement Papers | Free SMS | C Interview Questions | C++ Interview Questions | Quick2Host Review