Технология программирования
C++
Главная »
2018 » Март » 6 » Матрица Ввод Вывод
|
#include <iostream>
#include <ctime>
using namespace std;
int main()
{
setlocale(LC_ALL, "Russian");
srand(time(0));
const int n=3, m=4;
int a[n][m];
cout<<"Введите матрицу А"<<endl;
for (int i=0;i<n;i++)
{
for (int j=0;j<m;j++)
{
cin>>a[i][j];
}
}
cout<<"Введённая матрица А"<<endl;
for (int i=0;i<n;i++)
{
for (int j=0;j<m;j++)
{
cout<<a[i][j]<<" ";
}
cout<<endl;
}
int SummaPol=0, KolvoOtr=0, ProizvChet=1;
for (int i=0;i<n;i++)
{
for (int j=0;j<m;j++)
{
if (a[i][j]>0) SummaPol+=a[i][j];
if (a[i][j]<0) KolvoOtr++;
if (a[i][j]%2==0) ProizvChet*=a[i][j];
}
}
cout<<"Сумма положительных = "<<SummaPol<<endl;
cout<<"Количество отрицательных = "<<KolvoOtr<<endl;
cout<<"Произведение чётных = "<<ProizvChet<<endl;
system("pause");
return 0;
}
|
Просмотров: 286 |
Добавил: denjes
| Рейтинг: 0.0/0 |