x2311

Untitled

Dec 19th, 2021
940
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.94 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. const int SIZE = 4;
  6.  
  7. int main() {
  8.     int arr[][SIZE]{
  9.             {0,  3,  9,  5},
  10.             {1,  3,  4,  65},
  11.             {1,  32, 4,  0},
  12.             {7,  0,  4,  5},
  13.             {0,  3,  4,  5},
  14.             {1,  3,  4,  5},
  15.             {-7, -1, 4,  5},
  16.             {0,  3,  0,  5},
  17.             {1,  1,  -5, 5},
  18.             {4,  4,  4,  5},
  19.             {0,  3,  4,  0}
  20.     };
  21.     //array output
  22.     for (auto &i: arr) {
  23.         for (int j: i)
  24.             cout << " " << j;
  25.         cout << endl;
  26.     }
  27.     cout << endl;
  28.     int numberOfZeros = 0;
  29.     for (int i = 0; i < sizeof(arr) / (SIZE * sizeof(int)); i++) {
  30.         for (int j = 0; j < SIZE; j++) {
  31.             if (arr[i][j] == 0) {
  32.                 cout << i + 1 << " - " << j + 1 << ",  ";
  33.                 numberOfZeros++;
  34.             }
  35.         }
  36.     }
  37.     cout << endl << "number of zeros: " << numberOfZeros;
  38. }
  39.  
  40.  
  41.  
Advertisement
Add Comment
Please, Sign In to add comment