Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- /*
- int a, b;
- cin >> a >> b;
- int** x = (int**)calloc(a, sizeof(int*));
- int btmp = b;
- for (int i = 0; i < a; i++, b--) {
- x[i] = (int*)calloc(b, sizeof(int));
- }
- b = btmp;
- for (int i = 0; i < a; i++, b--) {
- for (int j = 0; j < b; j++) cout << x[i][j] << " ";
- cout << endl;
- } */
- int dim1 = 3, dim2 = 3, wdim = dim2;
- int** ptr2 = new int* [dim1];
- for (int i = 0; i < dim1; i++, wdim--) {
- ptr2[i] = new int[wdim];
- }
- wdim = dim2;
- for (int i = 0; i < dim1; i++, wdim--) for (int j = 0; j < wdim; j++) ptr2[i][j] = i + j;
- wdim = dim2;
- for (int i = 0; i < dim1; i++, wdim--) {
- for (int j = 0; j < wdim; j++) cout << ptr2[i][j] << " ";
- cout << endl;
- }
- for (int i = 0; i < dim1; i++) delete[] ptr2[i];
- delete[] ptr2;
- return 0;
- }
Add Comment
Please, Sign In to add comment