Complete these dialogues. Write them down. 1. — Don’t forget to catch falling leaves! — Why?
Ответы на вопрос:
— Why?
— You’ll have a good luck!
2. — Watch out! Be careful! Don’t break the mirror. It’s a bad sign!
— I know. It means 7 year’s bad luck.
3. — Don’t walk under a ladder!
— Don’t worry, I won’t.
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
const int SIZE = 5;
void fillAndShowArray(int[][SIZE], const int size);
int findMinElement(int[][SIZE], const int size);
int findMaxElement(int[][SIZE], const int size);
int main()
{
setlocale(LC_ALL, "rus");
int matrix[SIZE][SIZE] = {};
fillAndShowArray(matrix, SIZE); //заполняем и показываем массив
cout << endl;
cout << "Минимум: " << findMinElement(matrix, SIZE) << endl;
cout << "Максимум: " << findMaxElement(matrix, SIZE) << endl;
return 0;
}
void fillAndShowArray(int arr[][SIZE], const int size)
{
for (int i = 0; i < size; i++)
{
cout << "| ";
for (int j = 0; j < size; j++)
{
arr[i][j] = 30 + rand() % 31;
cout << arr[i][j] << " ";
}
cout << " |" << endl;
}
}
int findMinElement(int arr[][SIZE], const int size)
{
int min = arr[0][0];
for (int i = 0; i < size; i++)
{
for (int j = 0; j < size; j++)
{
if (arr[i][j] < min)
min = arr[i][j];
}
}
return min;
}
int findMaxElement(int arr[][SIZE], const int size)
{
int max = arr[0][0];
for (int i = 0; i < size; i++)
{
for (int j = 0; j < size; j++)
{
if (arr[i][j] > max)
max = arr[i][j];
}
}
return max;
}
Популярно: Другие предметы
-
Kto6to08.03.2021 01:21
-
Заяц69914.02.2022 14:37
-
revkova5a29.11.2020 02:41
-
Егор0212102.07.2021 23:38
-
Гвендолин1125.03.2021 16:35
-
Р00000024.02.2022 10:57
-
SmaGe201718.07.2022 08:01
-
Ученикdsgfgchugffwgc15.11.2022 01:02
-
exampllee125.05.2020 19:13
-
kolosochok129.03.2022 22:46