fork(1) download
  1. #include <iostream>
  2.  
  3. int rowReferences[5][1] = { 2,0,-1,1,3 };
  4.  
  5. void sort(int rowCount, int colCount, int sortColumn)
  6. {
  7. int pos, lower, temp;
  8.  
  9. for (int p = 0; p < rowCount; p++)
  10. {
  11. pos = p;
  12. lower = rowReferences[p][sortColumn];
  13. for (int j = p + 1; j < rowCount; j++) {
  14. if (rowReferences[j][sortColumn] < lower) {
  15. pos = j;
  16. lower = rowReferences[j][sortColumn];
  17. }
  18.  
  19. temp = rowReferences[p][sortColumn];
  20. rowReferences[p][sortColumn] = rowReferences[pos][sortColumn];
  21. rowReferences[pos][sortColumn] = temp;
  22. }
  23. }
  24. }
  25.  
  26. int main()
  27. {
  28. sort(5, 1, 0);
  29. for (int i = 0; i < 5; ++i)
  30. std::cout << rowReferences[i][0] << "\n";
  31. }
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
-1
0
2
1
3