Advertisement
awsmpshk

For Oleg

Apr 29th, 2020
424
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. template <typename T>
  6. T** createMas(int n,int m)
  7. {
  8.     T** mas = new T*[n];
  9.     for (int i = 0; i < n; ++i)
  10.     {
  11.         mas[i] = new T[m];
  12.         for (int j = 0; j < m; ++j)
  13.         {
  14.             cin >> mas[i][j];
  15.         }
  16.     }
  17.     return mas;
  18. }
  19.  
  20. template <typename T>
  21. void swapColumns(T** mas, int n, int m)
  22. {
  23.     for (int i = 0; i < n; ++i)
  24.     {
  25.         for (int j = 0; j < m; ++j)
  26.         {
  27.             T tmp = mas[i][j];
  28.             mas[i][j] = mas[i][m - (j + 1)];
  29.             mas[i][m - (j + 1)] = tmp;
  30.         }
  31.     }
  32. }
  33.  
  34. template <typename T>
  35. void printMas(T** mas, int n, int m)
  36. {
  37.     for (int i = 0; i < n; ++i)
  38.     {
  39.         for (int j = 0; j < m; ++j)
  40.         {
  41.             cout << mas[i][j] << " ";
  42.         }
  43.         cout << endl;
  44.     }
  45. }
  46.  
  47. template <typename T>
  48. void deleteMas(T** mas, int n, int m)
  49. {
  50.     for (int i = 0; i < n; ++i)
  51.     {
  52.         delete[] mas[i];
  53.     }
  54.     delete[] mas;
  55. }
  56.  
  57. int main()
  58. {
  59.     // some trash
  60.     return 0;
  61. }
Advertisement
RAW Paste Data Copied
Advertisement