fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. #define pi 3.14159265359
  5. #define el <<"\n"
  6.  
  7. int main() {
  8. ios::sync_with_stdio(false);
  9. cin.tie(nullptr);
  10. cout.tie(nullptr);
  11.  
  12. int n;
  13. cin>>n;
  14. int a[n];
  15.  
  16. for(int i = 0; i < n-1;i++){
  17. for(int j=0; j < n-i-1;i++){
  18. if(a[j] > a[j + 1]){
  19. swap(a[j],a[j + 1]);
  20. }
  21. }
  22. }
  23. cout<< " Sorted number is" el;
  24. for(int i = 0; i < n;i++){
  25. cout<< a[i] << " ";
  26. }
  27. return 0;
  28. }
Success #stdin #stdout 0.01s 5292KB
stdin
1 4 6 8 2
stdout
 Sorted number is
1643046960