fork(3) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int* selectionSort(int x[]);
  5.  
  6. int main()
  7. {
  8. int a[5] = {7, 6, 14, 3, 8};
  9. int *b = selectionSort(a);
  10. for (int i = 0; i <= 4; i++)
  11. {
  12. cout << b[i] << " ";
  13. }
  14. }
  15.  
  16. int* selectionSort(int x[])
  17. {
  18. int temp;
  19. for (int i = 0; i < 5; i++)
  20. {
  21. for (int j = i + 1; j<5; j++)
  22. {
  23. if (x[i] > x[j])
  24. {
  25. temp = x[i];
  26. x[i] = x[j];
  27. x[j] = temp;
  28. }
  29. }
  30. }
  31. return x;
  32. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
3  6  7  8  14