Предмет: Информатика,
автор: toffin
Си++
Дана матрица размером Nстрок и Mстолбцов. Найти количество положительных чисел в столбце.
Ответы
Автор ответа:
0
#include<iostream>
#include<cstdlib>
#include<ctime>
#include<locale>
#include<windows.h>
using namespace std;
int main()
{
setlocale(LC_ALL, "Russian");
srand(time(NULL));
const int n=12, m=12;
int a[n][m];
int s = 0;
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
a[i][j] = rand() % 2;
if(a[i][j]) a[i][j] = rand()%100;
else a[i][j] = rand()%50*(-2);
cout << a[i][j] << ' ';
}
cout << 'n';
}
cout << 'n';
int c;
cout << "Введите номер столбца: ";
cin >> c;
for(int i=0; i < 12; i++)
if(a[i][c] > 0) s++;
cout << "Количество положительных чисел в столбце " << c << ": " << s << 'n';
system("pause");
}
#include<cstdlib>
#include<ctime>
#include<locale>
#include<windows.h>
using namespace std;
int main()
{
setlocale(LC_ALL, "Russian");
srand(time(NULL));
const int n=12, m=12;
int a[n][m];
int s = 0;
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
a[i][j] = rand() % 2;
if(a[i][j]) a[i][j] = rand()%100;
else a[i][j] = rand()%50*(-2);
cout << a[i][j] << ' ';
}
cout << 'n';
}
cout << 'n';
int c;
cout << "Введите номер столбца: ";
cin >> c;
for(int i=0; i < 12; i++)
if(a[i][c] > 0) s++;
cout << "Количество положительных чисел в столбце " << c << ": " << s << 'n';
system("pause");
}
Похожие вопросы
Предмет: История,
автор: annashchetinkina
Предмет: Биология,
автор: Gospodbot
Предмет: Қазақ тiлi,
автор: nakupovaadina
Предмет: Алгебра,
автор: TrollLalkaPalka
Предмет: Математика,
автор: Аноним