fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. char** read_labyrinth (int rows, int cols)
  5. {
  6.  
  7. char **labyrinth = NULL;
  8. labyrinth = new char*[rows];
  9.  
  10. for (int i = 0; i < rows; i++) {
  11. labyrinth[i] = new char[cols];
  12. }
  13.  
  14. for (int i = 0; i < rows; i++) {
  15. for (int j = 0; j < cols; j++)
  16. {
  17. cin >> labyrinth[i][j];
  18. }
  19. }
  20. return labyrinth;
  21. }
  22. void print_labyrinth (char** maze, int rows, int cols)
  23. {
  24. cout << "labyrinth is : \n";
  25. for (int i = 0; i < rows; i++)
  26. {
  27. for (int j = 0; j < cols; j++)
  28. {
  29. cout << maze[i][j];
  30. }
  31. cout<<"\n";
  32. }
  33.  
  34. }
  35. int main() {
  36. int r, c;
  37. cout << "enter no of rows and colomuns \n";
  38. cin >> r >> c;
  39. print_labyrinth(read_labyrinth(r,c),r,c);
  40. return 0;
  41. }
Success #stdin #stdout 0s 3416KB
stdin
2 5
hello
india
stdout
enter no of rows and colomuns 
labyrinth is : 
hello
india