Advertisement
Guest User

Untitled

a guest
Dec 25th, 2021
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime>
  3. using namespace std;
  4. class matrix
  5. {
  6. private:
  7. int** a;
  8. int n, m;
  9. void friend change(int** A, int N, int M);
  10. public:
  11. matrix()
  12. {
  13. a = 0;
  14. n = 0;
  15. m = 0;
  16. }
  17. matrix(int N, int M)
  18. {
  19. n = N;
  20. m = M;
  21. a = new int* [n];
  22. for (int i = 0; i < n; ++i)
  23. {
  24. a[i] = new int[m];
  25. for (int j = 0; j < m; ++j) {
  26. a[i][j] = rand()%10;
  27. cout << a[i][j]<<" ";
  28. }
  29. cout << endl;
  30. }
  31. }
  32. void change(int** A, int N, int M);
  33. };
  34.  
  35. class coord {
  36. private:
  37. pair<int, int>cd;
  38. void friend change(pair<int, int>cd);
  39. public:
  40. coord() {
  41. cd=make_pair(0,0);
  42. };
  43. coord(int P, int L) {
  44. int p = P;
  45. int l = L;
  46. cd = make_pair(p, l);
  47. cout <<"\n" << cd.first << " " << cd.second << endl;
  48. };
  49. void change(pair<int, int>);
  50. };
  51.  
  52. void change(int** A, int N, int M, pair<int, int>) {
  53. int c = N;
  54. int g = M;
  55. int h = int* [c];
  56. for (int i = 0; i < c; ++i)
  57. {
  58. h[i] = new int[c];
  59. for (int j = 0; j < g; ++j) {
  60. h[i][j] = rand() % 10;
  61. cout << h[i][j] << " ";
  62. }
  63. cout << endl;
  64. }
  65. };
  66. int main()
  67. {
  68. srand(time(0));
  69. setlocale(LC_ALL, "Russian");
  70. matrix arr(4, 4);
  71. coord a(2, 4);
  72. coord b(1, 3);
  73. return 0;
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement