Загрузка данных


#include <iostream>
#include <cstdlib>
#include <ctime>
#include <cmath>
using namespace std;

const int N = 3;
const int M = 4;

void inputArray(int a[N][M]) {
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            a[i][j] = rand() % 21 - 10; 
        }
    }
}

void outputArray(int a[N][M]) {
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            cout << a[i][j] << "\t";
        }
        cout << endl;
    }
}

int countAbsMoreThan5(int a[N][M]) {
    int count = 0;

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            if (abs(a[i][j]) > 5) {
                count++;
            }
        }
    }

    return count;
}

int main() {
    system("chcp 65001 > nul");
    srand(time(0));

    int a[N][M];

    inputArray(a);

    cout << "Массив в виде матрицы:" << endl;
    outputArray(a);

    cout << "Количество элементов, у которых модуль больше 5: ";
    cout << countAbsMoreThan5(a) << endl;

    return 0;
}