VB icon

Selection Sort in C++

Email
Submitted on: 9/3/2016 3:11:23 AM
By: Jake R. Pomperada  
Level: Beginner
User Rating: By 1 Users
Compatibility: C++ (general)
Views: 2042
author picture
 
     A program that I wrote a long time ago in my C++ programming class in college to perform selection sort. The code is very simple and easy to use. Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com. My mobile number here in the Philippines is 09173084360.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
//**************************************
// Name: Selection Sort in C++
// Description:A program that I wrote a long time ago in my C++ programming class in college to perform selection sort. The code is very simple and easy to use.
Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
 
My mobile number here in the Philippines is 09173084360.
// By: Jake R. Pomperada
//**************************************

#include <iostream>
using namespace std;
#define MAX 5
void SelSort(int X[],int start,int stop)
{
int begin=start;
int smallsofar=begin;
int tmp;
if(start<stop)
{
for(int i=begin+1;i<=stop;i++)
 {
if(X[i] < X[smallsofar])
 smallsofar=i;
 }
 tmp=X[begin];
 X[begin]=X[smallsofar];
 X[smallsofar]=tmp;
 SelSort(X,start+1,stop);
}
}
int main()
{
int abc[MAX];
cout << "\t\t\t SELECTION SORT IN C++";
cout << "\n\t\t Created By: Mr. Jake R. Pomperada, MAED-IT";
cout << "\n\n";
for(int i=0;i<5;i++) {
cout << "Enter Item No.:" << i+1 << ":";
cin >> abc[i];
}
cout << "\n\t Original Arrangement of Numbers";
cout << "\n\n";
for(int i=0;i<5;i++)
{
cout << "\t " << abc[i] << " ";
}
SelSort(abc,0,MAX-1);
cout << "\n";
cout << "\n\t Sorted Arragmenent of Number";
cout << "\n\n";
for(int i=0;i<5;i++)
{
cout << "\t " << abc[i] << " ";
}
cout << "\n\n";
system("PAUSE");
}


Other 70 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.