Advertisement
Guest User

Untitled

a guest
Jun 20th, 2018
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 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. void SortMatrix(vector<vector<int>> & matrix)
  11. {
  12. int rows = matrix.size();
  13. int cols = matrix[0].size();
  14. }
  15.  
  16. void PrintMatrix(vector<vector<int>> & matrix)
  17. {
  18. for (auto & row : matrix) {
  19. for (auto & cell : row) {
  20. cout << cell << "\t";
  21. }
  22. cout << endl;
  23. }
  24. cout << endl;
  25. }
  26.  
  27. int main()
  28. {
  29. vector<vector<int>> m1 =
  30. {
  31. { 9, 8 },
  32. { 1, 12 },
  33. { 3, 5 },
  34. };
  35.  
  36. vector<vector<int>> m2 =
  37. {
  38. { 9, 8, 6 },
  39. { 4, 12, 2 },
  40. { 3, 5, 11 },
  41. };
  42.  
  43. SortMatrix(m1);
  44. PrintMatrix(m1);
  45.  
  46. SortMatrix(m2);
  47. PrintMatrix(m2);
  48. return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement