Си++ дана матрица размером nстрок и mстолбцов. найти количество положительных чисел в столбце.

panda312 panda312    1   09.06.2019 11:10    0

Ответы
shakurovagaliya shakurovagaliya  08.07.2020 08:22
#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");
}
ПОКАЗАТЬ ОТВЕТЫ
Другие вопросы по теме Информатика