/
monahov
/
learningcplusplus
Обзор
Документация
Войти
/
monahov
/
learningcplusplus
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Lesson 5.3.cpp
42 строки
1 KB
monahov
upload files
22 июл 2025, 18:14
22 июл 2025, 18:14
f02c27e
Код
Авторство
О чём код?
#include <iostream> int main() { setlocale(LC_ALL, "rus"); const int row = 3; const int col = 6; int arr[row][col] { { 33,5,2,6,501,0 }, { 1,4,8,3,2,8 }, { 100,200,300,-299, -3 }, }; int minElement{}; int maxElement{}; int minElementIndex[2]{}; int maxElementIndex[2]{}; std::cout << "Массив:" << std::endl; for (int i = 0; i < row; i++) { for (int j = 0; j < col; j++) { if (arr[i][j] < minElement) { minElement = arr[i][j]; minElementIndex[0] = i; minElementIndex[1] = j; } else if (arr[i][j] > maxElement) { maxElement = arr[i][j]; maxElementIndex[0] = i; maxElementIndex[1] = j; } std::cout << arr[i][j] << "\t"; } std::cout << std::endl; } std::cout << "Идекс минимального элемента: " << minElementIndex[0] << " " << minElementIndex[1] << std::endl; std::cout << "Идекс максимального элемента: " << maxElementIndex[0] << " " << maxElementIndex[1] << std::endl; return EXIT_SUCCESS; }