Advertisement
RenSafaray

Untitled

Mar 3rd, 2025
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.12 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.     int N, M;
  6.     cout << "Введите количество строк (N): ";
  7.     cin >> N;
  8.     cout << "Введите количество столбцов (M): ";
  9.     cin >> M;
  10.  
  11.     int A[N][M];
  12.     cout << "Введите элементы массива " << N << "x" << M << ":" << endl;
  13.     for (int i = 0; i < N; i++) {
  14.         for (int j = 0; j < M; j++) {
  15.             cin >> A[i][j];
  16.         }
  17.     }
  18.  
  19.     cout << "Массив до преобразования:" << endl;
  20.     for (int i = 0; i < N; i++) {
  21.         for (int j = 0; j < M; j++) {
  22.             cout << A[i][j] << " ";
  23.         }
  24.         cout << endl;
  25.     }
  26.  
  27.     for (int i = 0; i < N; i++) {
  28.         for (int j = 0; j < M; j++) {
  29.             if (A[i][j] < 0) {
  30.                 A[i][j] = A[i][j] / 4;
  31.             }
  32.         }
  33.     }
  34.  
  35.     cout << "Массив после преобразования:" << endl;
  36.     for (int i = 0; i < N; i++) {
  37.         for (int j = 0; j < M; j++) {
  38.             cout << A[i][j] << " ";
  39.         }
  40.         cout << endl;
  41.     }
  42.  
  43.     return 0;
  44. }
  45.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement