#include <iostream>
#include <windows.h>
#include <ctime>
#include <algorithm>
#include <iomanip>
using namespace std;
int main()
{
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
srand(time(NULL));
system("color 0A");
cout << "Введите размеры матрицы ";
size_t n, m;
cin >> n >> m;
auto **a = new int*[n];
for (size_t count = 0u; count < n; ++count)
a[count] = new int[m];
auto get_num = []()
{
auto value = rand() % 5;
cout << setw(5u) << value;
return value;
};
auto get_string = [a, n, m, get_num]()
{
auto str = new int[m];
generate(str, str + m, get_num);
cout << endl;
return str;
};
cout << "Исходная матрица: " << endl;
generate(a, a + n, get_string);
cout << "Поизведения для столбиков" << endl;
for (size_t u = 0u; u < m; ++u)
{
long long pp = 1;
for (size_t p = 0u; p < n; ++p)
{
pp *= a[p][u] ? a[p][u] : 1;
}
cout << setw(5u) << pp;
}
cout << endl;
system("pause");
return 0;
}
#include cstdlib
#include iostream
#include ctime
using namespace std;
int main()
{
int f[10],a[5][5],i,j;
for (i=0; i<10; i++)
{
f[i]=0;
}
for (i=0; i<5; i++)
{
for (j=0; j<5; j++)
{
a[i][j]=rand()%5;
cout << a[i][j] << " ";
f[j]+=a[i][j];
}
cout << "\n";
}
cout << " ";
for (i=0; i<5; i++)
{
cout << f[i] << " ";
}
cin.get();
}