Advertisement
khisby

Shorting Array Ascading

Nov 27th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. //Khisby Al Ghofari
  2. //06.2017.1.06852
  3. //Kelas B
  4. //Shorting Array ASC
  5. #include <iostream>
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11.     int a[5] = {1234,4,5,60,17};
  12.     for (int e=0;e<5;e++){
  13.         for (int c=0;c<5;c++){
  14.             int d = a[c];
  15.             if(a[c]>a[c+1]){
  16.                 a[c] = a[c+1];
  17.                 a[c+1] = d;
  18.             }
  19.         }
  20.     }
  21.  
  22.     for(int b=0;b<5;b++){
  23.         cout << a[b] << ",";
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement