Advertisement
Guest User

2_5366282596621746643.cpp

a guest
Jul 19th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.95 KB | None | 0 0
  1. /*Дан двухмерный массив размерностью 3×4.
  2.   Необхо- димо найти количество элементов значение которых равно нулю.*/
  3.  
  4. #include <iostream>
  5. #include <time.h>
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11.     srand(time(nullptr));
  12.     const int ROW = 3;
  13.     const int COL = 4;
  14.     int Array[ROW][COL];
  15.     int save = 0;
  16.  
  17.     for (int i = 0; i < ROW; i++)
  18.     {
  19.         for (int j = 0; j < COL; j++)
  20.         {
  21.             Array[i][j] = rand() % 10;
  22.         }
  23.     }
  24.  
  25.     for (int i = 0; i < ROW; i++)
  26.     {
  27.         for (int j = 0; j < COL; j++)
  28.         {
  29.             if (Array[i][j] == 0)
  30.             {
  31.                 save++;
  32.             }
  33.             cout << Array[i][j] << ' ';
  34.         }
  35.         cout << endl;
  36.     }
  37.     if (save >= 1)
  38.     {
  39.         cout << "The number of zeros in the array " << save << endl;
  40.     }
  41.     else
  42.     {
  43.         cout << "No zeros in the array " << endl;
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement