Selection Sort in C++

Language
Selection Sort in C++. By this method, you can easily sort a for loop code and array. Below are the sample codes:
  1. #include<iostream>
  2. #include<conio.h>
  3. using namespace std;
  4. int main()
  5. {
  6.         int arraylength,num[1000],num1,d,num2=0;
  7.         cout<<"Enter the total no. of element: ";
  8.         cin>>arraylength;
  9.        
  10.         for(int i=0;i<arraylength;i++)
  11.     { cout<<"Enter No."<<i+1<<": ";
  12.                 cin>>num[i],num[d]; }
  13.                
  14.      { cout<<" \n" << endl; }
  15.      for(int d=0;d<arraylength;d++){
  16.      cout<<num[d]<<" " << "\n" << endl;
  17.  
  18.  
  19.         cout<<"UNSORTED ARRAY : ";
  20.         for(int i =0;i<arraylength;i++){
  21.                 cout<<num[i]<<" ";
  22.         }      
  23.        
  24.  
  25.         cout<<endl<<"SORTED ARRAY : ";
  26.        
  27.         for(int a=0; a<arraylength-1;a++){
  28.                 for(int b=0; b<arraylength-a-1;b++){
  29.                         if(num[b]<num[b+1]){
  30.                                 num1=num[b];
  31.                                 num[b]=num[b+1];
  32.                                 num[b+1]=num1;
  33.                         }
  34.                 }
  35.         }
  36.         for(int r=0;r<arraylength;r++){
  37.                 cout<<num[r]<<" ";
  38.         }
  39. }      
  40. return 0;              
  41. }

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.

Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.

FOR YOUR OWN SAFETY, PLEASE:

1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.

Comments

Thanks author this project will help for my project. more usefull

Add new comment