Advertisement
RenSafaray

Untitled

Mar 3rd, 2025
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.     const int rows = 3;
  6.     const int cols = 4;
  7.     int A[rows][cols];
  8.  
  9.     cout << "Введите элементы массива 3x4:" << endl;
  10.     for (int i = 0; i < rows; i++) {
  11.         for (int j = 0; j < cols; j++) {
  12.             cin >> A[i][j];
  13.         }
  14.     }
  15.  
  16.     int count = 0;
  17.     for (int i = 0; i < rows; i++) {
  18.         for (int j = 0; j < cols; j++) {
  19.             if (A[i][j] % 4 == 2) {
  20.                 count++;
  21.             }
  22.         }
  23.     }
  24.  
  25.     cout << "Количество элементов, которые при делении на 4 дают остаток 2: " << count << endl;
  26.  
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement