35657

Untitled

Nov 25th, 2023
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. #include <time.h> // для подключения функции time()
  4.  
  5. using namespace std;
  6.  
  7.  
  8.  
  9. int main() {
  10.  
  11.     setlocale(LC_ALL, "ru");
  12.  
  13.     const int row = 3;
  14.  
  15.     const int col = 4;
  16.  
  17.     int arr[row][col];
  18.  
  19.     srand(time(NULL));
  20.  
  21.     for (int i = 0; i < row; i++) {
  22.         for (int j = 0; j < col; j++) {
  23.             arr[i][j] = rand() % 5;
  24.             cout << arr[i][j] << "\t";
  25.         }
  26.         cout << endl;
  27.     }
  28.  
  29.     int count = 0;
  30.  
  31.     for (int i = 0; i < row; i++) {
  32.         for (int j = 0; j < col; j++) {
  33.             if (arr[i][j] == 0) {
  34.                 count++;
  35.             }
  36.         }
  37.     }
  38.     cout << count << endl;
  39.  
  40. }
  41.  
Add Comment
Please, Sign In to add comment