На 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;}
Полный текст программы
//PascalABC.NET версия 3.4.2.1991 от 03.03.19
var
a, b, c: integer;
begin
A := -7;
b := 36;
a := b * (-3) - (a * 2);
b := a - 23 + b;
if a <> b then c := a + b
else c := a - 5;
writeln('a = ', a, ', b = ', b, ', c = ', c);
a := 65;
b := 45;
a := b - a div 5;
b := a + b mod 2;
if a < b then c := b + a
else c := a - b;
a := -75;
b := 33;
a := b * 2 - a;
b := a + b div 2;
if a >= b then c := a - b * 4
else c := a + 25;
a := 3;
b := 2;
a := a - 2 * 3;
if b >= a then c := a * 2
else c := a - 5 mod 2;
a := 33;
b := 22;
a := b - a * 2;
b := b - a;
if a > b then c := b + 7
else c := b + 4;
a := 87;
b := -21;
a := b + 44;
b := (a - 6 + b) div 3;
if a <> b then c := a - 2 * b
else c := a + 2 * b;
a := 2;
b := 5;
if b mod 2 = 0 then c := a * b div 3
else c := a * b div 4;
a := -4;
b := -1;
a := -b + a * 2;
b := a - b * 2;
if a < b then c := b - a
a := -31;
b := -13;
a := -(b + a) mod 20;
b := b + a;
if a > b then c := a - b
else c := b - a;
b := -98;
a := (a + b * (-2)) div 10;
if a > b then c := a - 4
else c := 4;
end.
Вывод
a = -94, b = -81, c = -175
a = 32, b = 33, c = 65
a = 141, b = 157, c = 166
a = -3, b = 2, c = -6
a = -44, b = 66, c = 70
a = 23, b = -1, c = 25
a = 2, b = 5, c = 2
a = -7, b = -5, c = 2
a = 4, b = -9, c = 13
a = 19, b = -117, c = 15
На 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;
}
Полный текст программы
//PascalABC.NET версия 3.4.2.1991 от 03.03.19
var
a, b, c: integer;
begin
A := -7;
b := 36;
a := b * (-3) - (a * 2);
b := a - 23 + b;
if a <> b then c := a + b
else c := a - 5;
writeln('a = ', a, ', b = ', b, ', c = ', c);
a := 65;
b := 45;
a := b - a div 5;
b := a + b mod 2;
if a < b then c := b + a
else c := a - b;
writeln('a = ', a, ', b = ', b, ', c = ', c);
a := -75;
b := 33;
a := b * 2 - a;
b := a + b div 2;
if a >= b then c := a - b * 4
else c := a + 25;
writeln('a = ', a, ', b = ', b, ', c = ', c);
a := 3;
b := 2;
a := a - 2 * 3;
if b >= a then c := a * 2
else c := a - 5 mod 2;
writeln('a = ', a, ', b = ', b, ', c = ', c);
a := 33;
b := 22;
a := b - a * 2;
b := b - a;
if a > b then c := b + 7
else c := b + 4;
writeln('a = ', a, ', b = ', b, ', c = ', c);
a := 87;
b := -21;
a := b + 44;
b := (a - 6 + b) div 3;
if a <> b then c := a - 2 * b
else c := a + 2 * b;
writeln('a = ', a, ', b = ', b, ', c = ', c);
a := 2;
b := 5;
if b mod 2 = 0 then c := a * b div 3
else c := a * b div 4;
writeln('a = ', a, ', b = ', b, ', c = ', c);
a := -4;
b := -1;
a := -b + a * 2;
b := a - b * 2;
if a < b then c := b - a
else c := a - b;
writeln('a = ', a, ', b = ', b, ', c = ', c);
a := -31;
b := -13;
a := -(b + a) mod 20;
b := b + a;
if a > b then c := a - b
else c := b - a;
writeln('a = ', a, ', b = ', b, ', c = ', c);
a := 2;
b := -98;
a := (a + b * (-2)) div 10;
b := b - a;
if a > b then c := a - 4
else c := 4;
writeln('a = ', a, ', b = ', b, ', c = ', c);
end.
Вывод
a = -94, b = -81, c = -175
a = 32, b = 33, c = 65
a = 141, b = 157, c = 166
a = -3, b = 2, c = -6
a = -44, b = 66, c = 70
a = 23, b = -1, c = 25
a = 2, b = 5, c = 2
a = -7, b = -5, c = 2
a = 4, b = -9, c = 13
a = 19, b = -117, c = 15