Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "iostream"
- #include "iomanip"
- using namespace std;
- int main() {
- int rows, columns;
- cout << "Please , enter number of rows\n";
- cin >> rows;
- cout << "Please , enter number of columns\n";
- cin >> columns;
- int** matrix = new int* [rows];
- for (int i = 0; i < rows; i++) {
- matrix[i] = new int[columns];
- }
- int new_rows, new_columns;
- cout << "Please , enter number of rows\n";
- cin >> new_rows;
- cout << "Please , enter number of columns\n";
- cin >> new_columns;
- int** new_matrix = new int* [new_rows];
- for (int i = 0; i < new_rows; i++) {
- new_matrix[i] = new int[new_columns];
- }
- int** sum_matrix = new int* [new_rows];
- for (int i = 0; i < new_rows; i++) {
- new_matrix[i] = new int[new_columns];
- }
- for (int i = 0; i < rows; i++) {
- for (int j = 0; j < columns; j++) {
- matrix[i][j] = rand() % 10 + 1;
- }
- }
- for (int i = 0; i < rows; i++) {
- for (int j = 0; j < columns; j++) {
- new_matrix[i][j] = rand() % 10 + 1;
- }
- }
- for (int i = 0; i < rows; i++) {
- for (int j = 0; j < columns; j++) {
- cout << setw(4) << matrix[i][j] ;
- }
- cout << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement