Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int N, M;
- cout << "Введите количество строк (N): ";
- cin >> N;
- cout << "Введите количество столбцов (M): ";
- cin >> M;
- int A[N][M];
- cout << "Введите элементы массива " << N << "x" << M << ":" << endl;
- for (int i = 0; i < N; i++) {
- for (int j = 0; j < M; j++) {
- cin >> A[i][j];
- }
- }
- cout << "Массив до преобразования:" << endl;
- for (int i = 0; i < N; i++) {
- for (int j = 0; j < M; j++) {
- cout << A[i][j] << " ";
- }
- cout << endl;
- }
- for (int i = 0; i < N; i++) {
- for (int j = 0; j < M; j++) {
- if (A[i][j] < 0) {
- A[i][j] = A[i][j] / 4;
- }
- }
- }
- cout << "Массив после преобразования:" << endl;
- for (int i = 0; i < N; i++) {
- for (int j = 0; j < M; j++) {
- cout << A[i][j] << " ";
- }
- cout << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement