На 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;
}
ответ:
#include "stdafx.h"
#include
using namespace std;
struct complex // структура "хранения" комплексного числа
{ float re; // действительная часть
float im; // мнимая часть
};
void print( char * txt, complex x) // вывод комплексного числа
{
printf("%s=(%f,%fi)", txt, x.re, x.im);
return;
};
complex new_complex(float a, float b) // задать значение комплексному числу
{ complex temp;
temp.re=a;
temp.im=b;
return temp;
};
complex plus_complex(complex a, complex b) // сложить два комплексных чисел
{ complex temp;
temp.re=a.re+b.re;
temp.im=a.im+b.im;
return temp;
}
int main() // простая тестовая программа
{
complex z;
printf( "vvedite re и im 1 chisla: ");
cin > > z.re > > z.im;
print( "z", z); printf("\n");
complex q;
printf( "vvedite re и im 2 chisla: ");
cin > > q.re > > q.im;
print("q", q); printf("\n");
complex sum;
sum=plus_complex(z,q);
print("q+z", sum); printf("\n");
return 0;
}
0