Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <time.h>
- using namespace std;
- const int N = 3;
- const int P = 4;
- int main()
- {
- int a[N][P];
- int b[N][P]; // чтобы провести сумму матриц , то матрицы должны быть равны
- int sum[N][P];
- int F;
- setlocale(LC_ALL, "Rus");
- srand(time(NULL));
- cout << "Введите число " << endl;
- cin >> F;
- cout << " Найтие cумму матриц . " << endl;
- cout << "Вывод элементов" << endl;
- cout << "Для матрицы А" << endl;
- for (int i = 0; i < N; i++)
- {
- for (int j = 0; j < P; j++)
- {
- a[i][j] = rand() % 12;
- cout << a[i][j] << " ";
- }
- cout << endl;
- }
- cout << endl;
- cout << "Для матрицы B " << endl;
- for (int i = 0; i < N; i++)
- {
- for (int j = 0; j < P; j++)
- {
- b[i][j] = rand() % 12;
- cout << b[i][j] << " ";
- }
- cout << endl;
- }
- cout << endl;
- cout << "Умножение матрицы B на число равно = " << endl;
- for (int i = 0; i < N; i++)
- {
- for (int j = 0; j < P; j++)
- {
- b[i][j] = b[i][j] * F;
- cout << b[i][j]<< " ";
- }
- cout << endl;
- }
- cout << endl;
- cout << "Сумма матриц равна = " << endl;
- for (int i = 0; i < N; i++)
- {
- for (int j = 0; j < P; j++)
- {
- sum[i][j] = a[i][j] + b[i][j];
- cout << sum[i][j] << " ";
- }
- cout << endl;
- }
- cout << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement