thevals

кто прочитал тот лох

Feb 18th, 2022 (edited)
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.82 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main() {
  4.     /*
  5.     int a, b;
  6.     cin >> a >> b;
  7.     int** x = (int**)calloc(a, sizeof(int*));
  8.     int btmp = b;  
  9.     for (int i = 0; i < a; i++, b--) {
  10.         x[i] = (int*)calloc(b, sizeof(int));
  11.     }
  12.     b = btmp;
  13.     for (int i = 0; i < a; i++, b--) {
  14.         for (int j = 0; j < b; j++) cout << x[i][j] << " ";
  15.         cout << endl;
  16.     } */
  17.  
  18.  
  19.     int dim1 = 3, dim2 = 3, wdim = dim2;
  20.     int** ptr2 = new int* [dim1];
  21.     for (int i = 0; i < dim1; i++, wdim--) {
  22.         ptr2[i] = new int[wdim];
  23.     }
  24.     wdim = dim2;
  25.     for (int i = 0; i < dim1; i++, wdim--) for (int j = 0; j < wdim; j++) ptr2[i][j] = i + j;
  26.     wdim = dim2;
  27.     for (int i = 0; i < dim1; i++, wdim--) {
  28.         for (int j = 0; j < wdim; j++) cout << ptr2[i][j] << " ";
  29.         cout << endl;
  30.     }
  31.     for (int i = 0; i < dim1; i++) delete[] ptr2[i];
  32.     delete[] ptr2;
  33.     return 0;
  34. }
Add Comment
Please, Sign In to add comment