From 39096faf4bc9a7cf77667a871380cc89a0dcc293 Mon Sep 17 00:00:00 2001 From: Misha Date: Tue, 30 Sep 2025 15:17:58 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=B4=D0=B0=D0=BB=D0=B8=D1=82=D1=8C=20ma?= =?UTF-8?q?xElem.cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- maxElem.cpp | 100 ---------------------------------------------------- 1 file changed, 100 deletions(-) delete mode 100644 maxElem.cpp diff --git a/maxElem.cpp b/maxElem.cpp deleted file mode 100644 index f9e218b..0000000 --- a/maxElem.cpp +++ /dev/null @@ -1,100 +0,0 @@ -#include -#include -#define N 5 -#define B 5 -using namespace std; - -int maxElem(int x, int y) { - int max = (x > y) ? x : y; - return max; -} - -int maxElem(int x, int y, int z) { - int max = (x > y) ? x : y; - max = (max > z) ? max : z; - return max; -} - -int maxElem(int a[], int n) { - int max = a[0]; - for (int i = 1; i < n; i++) { - if (a[i] > max) { - max = a[i]; - } - } - return max; -} - -int maxElem(int a[][N], int n) { - int max = a[0][0]; - for (int i = 0; i < n; i++) { - for (int j = 0; j < N; j++) { - if (a[i][j] > max) { - max = a[i][j]; - } - } - } - return max; -} - -int maxElem(int a[][N][B], int n) { - int max = a[0][0][0]; - for (int i = 0; i < n; i++) { - for (int j = 0; j < N; j++) { - for (int k = 0; k < B; k++) { - if (a[i][j][k] > max) { - max = a[i][j][k]; - } - } - } - } - return max; -} - -int main() { - srand(time(0)); - setlocale(0, ""); - - int x = rand() % 100; - int y = rand() % 100; - int z = rand() % 100; - cout << "Случайные числа: x = " << x << ", y = " << y << ", z = " << z << endl; - cout << "max(2): " << maxElem(x, y) << endl; - cout << "max(3): " << maxElem(x, y, z) << endl << endl; - - int arr1[5]; - cout << "Одномерный массив: "; - for (int i = 0; i < 5; i++) { - arr1[i] = rand() % 100; - cout << arr1[i] << " "; - } - cout << "\nmax(1D): " << maxElem(arr1, 5) << endl << endl; - - int arr2[2][N]; - cout << "Двумерный массив:\n"; - for (int i = 0; i < 2; i++) { - for (int j = 0; j < N; j++) { - arr2[i][j] = rand() % 100; - cout << arr2[i][j] << "\t"; - } - cout << endl; - } - cout << "max(2D): " << maxElem(arr2, 2) << endl << endl; - - int arr3[2][N][B]; - cout << "Трехмерный массив:\n"; - for (int i = 0; i < 2; i++) { - cout << "Плоскость " << i << ":\n"; - for (int j = 0; j < N; j++) { - for (int k = 0; k < B; k++) { - arr3[i][j][k] = rand() % 100; - cout << arr3[i][j][k] << "\t"; - } - cout << endl; - } - cout << endl; - } - cout << "max(3D): " << maxElem(arr3, 2) << endl; - - return 0; -} \ No newline at end of file