fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. int a[]= {9,8,7,6,5,4,3,2,1};
  7. int length=9;
  8. for (int i=0; i<length; i++){
  9. for (int j=0; j<length-1; j++){
  10. if (a[j]>a[j+1]){
  11. int temp;
  12. temp=a[j];
  13. a[j]=a[j+1];
  14. a[j+1]=temp;
  15. }
  16.  
  17. }
  18. }
  19. for (int i=0; i<length; i++){
  20.  
  21. cout<<a[i]<<"";
  22. cout<<endl<<endl;
  23. }
  24.  
  25. return 0;
  26. }
Success #stdin #stdout 0.01s 5304KB
stdin
Standard input is empty
stdout
1

2

3

4

5

6

7

8

9