Advertisement
Guest User

Untitled

a guest
Feb 24th, 2020
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. #include <iostream>
  2. #include <climits>
  3.  
  4. int** f_createArray(int, int);
  5. void f_fillArray(int**, int, int);
  6. void f_deleteArray(int**, int);
  7. void showArray(int**, int, int);
  8.  
  9. int main() {
  10.  
  11. int row,column;
  12. std::cin >> row >> column;
  13. int** t = f_createArray(row, column);
  14. f_fillArray(t, row, column);
  15.  
  16.  
  17. return 0;
  18. }
  19.  
  20. /*int maxSubArraySum(int** tab,int row,int column) {
  21.  
  22. int min = SHRT_MIN;
  23. int max = SHRT_MAX;
  24.  
  25.  
  26.  
  27. }*/
  28.  
  29. void showArray() {
  30.  
  31. }
  32.  
  33. void f_fillArray(int** t, int row, int column) {
  34.  
  35. for (int i = 0; i < row; ++i)
  36. for (int j = 0; j < column; ++j)
  37. std::cin >> t[i][j];
  38.  
  39.  
  40. }
  41.  
  42. int** f_createArray(int row, int column) {
  43.  
  44. int** tab = nullptr;
  45.  
  46. try {
  47. tab = new int* [row];
  48. }
  49.  
  50. catch (std::bad_alloc& b) {
  51. std::cout << "bad alloc: " << b.what() << std::endl;
  52. }
  53. for (int i = 0; i < row; ++i)
  54. try {
  55. tab[i] = new int[column];
  56. }
  57. catch (std::bad_alloc& b) {
  58. std::cout << "bad alloc: " << b.what() << std::endl;
  59. }
  60.  
  61. return tab;
  62. }
  63.  
  64. void f_deleteArray(int** t, int column) {
  65. for (int i = 0; i < column; ++i)
  66. delete[]t[i];
  67. delete[]t;
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement