fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void sortArray(int myArray[], int size)
  5. {
  6. for(int i=1;i<size;i++)
  7. {
  8. for(int j=size;j>i+1;j--)
  9. {
  10. if(myArray[j]<myArray[j-1])
  11. {
  12. int temp = myArray[j];
  13. myArray[j] = myArray[j-1];
  14. myArray[j-1] = temp;
  15. }
  16. }
  17. }
  18. }
  19.  
  20. int main()
  21. {
  22. int a[] = {13, 49, 8, 12, 27, 64, 53};
  23. int length = 7;
  24. sortArray(a, length);
  25. cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<" "<<a[3]<<" "<<a[4]<<" "<<a[5]<<" "<<a[6]<<" ";
  26. return 0;
  27. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
13 49 -1215868720 8 12 27 53