Advertisement
Guest User

Untitled

a guest
Sep 16th, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.14 KB | None | 0 0
  1. #include "iostream"
  2. #include "iomanip"
  3. using namespace std;
  4.  
  5. int main() {
  6.     int rows, columns;
  7.     cout << "Please , enter number of rows\n";
  8.     cin >> rows;
  9.     cout << "Please , enter number of columns\n";
  10.     cin >> columns;
  11.  
  12.     int** matrix = new int* [rows];
  13.     for (int i = 0; i < rows; i++) {
  14.         matrix[i] = new int[columns];
  15.     }
  16.  
  17.  
  18.     int new_rows, new_columns;
  19.     cout << "Please , enter number of rows\n";
  20.     cin >> new_rows;
  21.     cout << "Please , enter number of columns\n";
  22.     cin >> new_columns;
  23.    
  24.     int** new_matrix = new int* [new_rows];
  25.     for (int i = 0; i < new_rows; i++) {
  26.         new_matrix[i] = new int[new_columns];
  27.     }
  28.  
  29.     int** sum_matrix = new int* [new_rows];
  30.     for (int i = 0; i < new_rows; i++) {
  31.         new_matrix[i] = new int[new_columns];
  32.     }
  33.  
  34.     for (int i = 0; i < rows; i++) {
  35.         for (int j = 0; j < columns; j++) {
  36.             matrix[i][j] = rand() % 10 + 1;
  37.         }
  38.     }
  39.  
  40.     for (int i = 0; i < rows; i++) {
  41.         for (int j = 0; j < columns; j++) {
  42.             new_matrix[i][j] = rand() % 10 + 1;
  43.         }
  44.     }
  45.  
  46.  
  47.  
  48.     for (int i = 0; i < rows; i++) {
  49.         for (int j = 0; j < columns; j++) {
  50.             cout << setw(4) << matrix[i][j] ;
  51.         }
  52.         cout << endl;
  53.     }
  54.  
  55.     return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement