daily pastebin goal
27%
SHARE
TWEET

SlectionSort()

delvinkrasniqi Jan 24th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //SelectionSort()
  2.  
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int size,A[size] , i , j , tmp;
  9.    
  10.     cout <<"Shenoni gjatesine e vargut : ";
  11.     cin >> size;
  12.    
  13.     cout <<"Sheno elementet : " <<endl;
  14.    
  15.     for (int i=0;i<size;i++)
  16.     {
  17.         cin >> A[i];
  18.     }
  19.    
  20.     // Sortimi
  21.    
  22.     for (int i=0;i<size;i++)
  23.     {
  24.         for (j=i+1;j<size;j++)
  25.         {
  26.             if (A[i]>A[j])
  27.             {
  28.                 tmp=A[i];
  29.                 A[i]=A[j];
  30.                 A[j]=tmp;
  31.             }
  32.         }
  33.     }
  34.    
  35.     // Vargu i sortuar
  36.    
  37.     for (int i=0;i<size;i++)
  38.     {
  39.         cout << A[i] << " ";
  40.     }
  41. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top