fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void show(const int *const *m, unsigned rows, unsigned cols) {
  5. for (int i=0; i<rows; ++i) {
  6. for (int j=0; j<rows; ++j) {
  7. cout << m[i][j] << " | ";
  8. }
  9. cout << endl;
  10. }
  11. }
  12.  
  13. int main() {
  14. const size_t ARRAY_SIZE = 2;
  15. int a[ARRAY_SIZE][ARRAY_SIZE] =
  16. {{1, 2},
  17. {2, 1}};
  18.  
  19.  
  20. int **b = new int*[ARRAY_SIZE];
  21. for (int i=0; i<ARRAY_SIZE; ++i) {
  22. b[i] = a[i];
  23. }
  24.  
  25. show(b, ARRAY_SIZE, ARRAY_SIZE);
  26.  
  27. delete b;
  28. return 0;
  29. }
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
1 | 2 | 
2 | 1 |