Advertisement
Guest User

Untitled

a guest
Jun 19th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <vector>
  3. #include <iostream>
  4.  
  5. using namespace std;
  6.  
  7. // !!!
  8. // Write function Sort, that will sort the rows of matrix in ascending order.
  9. // Sorting must be done in-place.
  10.  
  11. void SortMatrix(vector<vector<int>> & matrix)
  12. {
  13. int rows = matrix.size();
  14. int cols = matrix[0].size();
  15. }
  16.  
  17. void PrintMatrix(vector<vector<int>> & matrix)
  18. {
  19. for (auto & row : matrix) {
  20. for (auto & cell : row) {
  21. cout << cell << "\t";
  22. }
  23. cout << endl;
  24. }
  25. cout << endl;
  26. }
  27.  
  28. int main()
  29. {
  30. vector<vector<int>> m1 =
  31. {
  32. { 9, 8 },
  33. { 1, 12 },
  34. { 3, 5 },
  35. };
  36.  
  37. vector<vector<int>> m2 =
  38. {
  39. { 9, 8, 6 },
  40. { 4, 12, 2 },
  41. { 3, 5, 11 },
  42. };
  43.  
  44. SortMatrix(m1);
  45. PrintMatrix(m1);
  46.  
  47. SortMatrix(m2);
  48. PrintMatrix(m2);
  49.  
  50. return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement