Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5. int main() {
  6.     int **a = NULL;
  7.     int *b = NULL;
  8.  
  9.     int n = 5;
  10.     int m = 10;
  11.     int count = 0;
  12.  
  13.     a = new int * [n];
  14.     for (int i = 0; i < n; i++) {
  15.         a[i] = new int [m];
  16.         for (int j = 0; j < m; j++) {
  17.             a[i][j] = count++;
  18.         }
  19.     }
  20.  
  21.     for (int i = 0; i < n; i++) {
  22.         for (int j = 0; j < m; j++) {
  23.             cout << a[i][j] << "\t";
  24.         }
  25.         cout << endl;
  26.     }
  27.     b = (int *)a;
  28.     cout << "Hello: " << a[3][0] << endl;
  29.     cout << "Hello 1: " << b[3] << endl;
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement