На C++
#include <iostream>using std::cout;
using std::cin;using std::endl;#include <cstdlib>using std::rand;using std::srand;#include <ctime>using std::time;int main(){ int B[4][5]; int sum[5] = { 0 }; long product = 1; srand(time(0)); //Инициализировать массива значениями от 0 до 9 и вывести таблицу на экран for(int i = 0; i < 4; i++) { for(int j = 0; j < 5; j++) { B[i][j] = rand() % 10; cout << B[i][j] << ' '; } cout << endl; } cout << endl; //Записать в одномерный массив сумму эллементов столбца for(int i = 0; i < 5; i++) { for(int j = 0; j < 4; j++) { sum[i] += B[j][i]; } }
//Вывести на экран значения одномерного массива for(int i = 0; i < 5; i++) { cout << sum[i] << ' '; } //Вычесление произведения(умножения) for(int i = 0; i < 5; i++) { product *= sum[i]; } cout << "\n\nProduct = " << product << endl;
cin.get(); return 0;}
Поделитесь своими знаниями, ответьте на вопрос:
JAVA Напишите результат выполнения логических операций «и», «или», «исключающее или», «не» для a (false, true) b (false)
На C++
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
#include <cstdlib>
using std::rand;
using std::srand;
#include <ctime>
using std::time;
int main()
{
int B[4][5];
int sum[5] = { 0 };
long product = 1;
srand(time(0));
//Инициализировать массива значениями от 0 до 9 и вывести таблицу на экран
for(int i = 0; i < 4; i++)
{
for(int j = 0; j < 5; j++)
{
B[i][j] = rand() % 10;
cout << B[i][j] << ' ';
}
cout << endl;
}
cout << endl;
//Записать в одномерный массив сумму эллементов столбца
for(int i = 0; i < 5; i++)
{
for(int j = 0; j < 4; j++)
{
sum[i] += B[j][i];
}
}
//Вывести на экран значения одномерного массива
for(int i = 0; i < 5; i++)
{
cout << sum[i] << ' ';
}
//Вычесление произведения(умножения)
for(int i = 0; i < 5; i++)
{
product *= sum[i];
}
cout << "\n\nProduct = " << product << endl;
cin.get();
return 0;
}