fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int arr[6]={7,8,5,2,4,6};
  8. for(int i=0;i<5;i++)
  9. {
  10. for(int j=0;j<5-i;j++)
  11. {
  12. if(arr[j]>arr[j+1])
  13. swap(arr[j],arr[j+1]);
  14. }
  15. }
  16. for(int k=0;k<6;k++)
  17. cout<<arr[k]<<endl;
  18. return 0;
  19. }
Success #stdin #stdout 0s 4524KB
stdin
Standard input is empty
stdout
2
4
5
6
7
8