Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <windows.h>
- #include <cstdlib>
- #include <time.h>
- using namespace std;
- int main(){
- setlocale(0,"rus");
- SetConsoleOutputCP(1251);
- SetConsoleCP(1251);
- srand(time(0));
- int n = 5;
- int a[5][5];
- int k;
- float s1, s2, p;
- cout << "Исходная матрица:" << endl;
- for (int i = 0; i < n; i++)
- {
- cout << endl;
- for (int j = 0; j < n; j++)
- {
- a[i][j] = -n / 2 + rand() % (n * n);
- cout << a[i][j] ;
- }
- }
- cout<<endl;
- cout << "Введите номер строки: " << endl;
- cin >> k;
- if (k < 1 || k > 5)
- {
- return -1;
- }
- k -= 1;
- s1 = 0;
- s2 = 0;
- for (int j = 0; j < n; j++)
- {
- s1 = s1 + a[k][j];
- s2 = s2 + a[j][j];
- }
- cout << "Сумма в строке: " << s1 << ", Сумма диагонали: " << s2 << endl;
- cout << "Произведение: " << s1 * s2 << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement