Двумерные массивы (матрицы)

Дана квадратная матрица . Получить последовательность чисел , равных произведениям положительных элементов столбцов.

#include <iostream.h>

#include <conio.h>

void main(){

const int str=3,stb=3;

int a[str][stb]={{1,-2,3},{-3,4,-5},{-6,3,1}};

float b[stb];

//Conclusion of a matrix

cout<<"matrix:"<<endl;

for (int i=0;i<str;i++){

for (int j=0;j<stb;j++)cout<<a[i][j]<<' ';

cout<<endl;}

//Calculation product of positive elements of columns

cout<<"Result product of positive elements of columns:"<<endl;

for (int j=0;j<stb;j++){

float prod=1;

for (int i=0;i<str;i++)if(a[i][j]>=0)prod*=a[i][j];

b[j]=prod;}

for(int j=0;j<stb;j++)

cout<<b[j]<<' ';

getch();}

Задание №14


Понравилась статья? Добавь ее в закладку (CTRL+D) и не забудь поделиться с друзьями:  



double arrow
Сейчас читают про: