#include <iostream>
#include <cmath>
#include <ctime>
using namespace std;
void task214()
{
cout << "task(a)" << endl;
srand(time(0));
const int size = 15;
int i = 0, max=0;
int arr1[size];
for (i = 0; i < size; i++)
{
arr1[i] = rand() % 20;
cout << arr1[i] << " ";
if (arr1[i] > max)
{
max = arr1[i];
}
}
cout << endl << endl;
cout <<"Max: "<< max << endl;
for (i = 0; i < size-1; i++)
{
if (arr1[i] == max)
{
arr1[i] = arr1[i++];
}
cout << arr1[i] << " ";
}
cout << endl << endl;
cout << "task(b)" << endl;
srand(time(0));
int min = 20;
int arr2[size];
for (i = 0; i < size; i++)
{
arr2[i] = rand() % 20;
cout << arr2[i] << " ";
if (arr2[i] < min)
{
min = arr2[i];
}
}
cout << endl << endl;
cout <<"Min: "<< min << endl;
for (i = 0; i < size-1; i++)
{
if (arr2[i] == min)
{
arr2[i] = arr2[i++];
}
cout << arr2[i] << " ";
}
cout << endl << endl;
}
void task226()
{
srand(time(0));
const int size = 5;
int arr1[size], arr2[size];
cout << "Array 1: ";
for (int i = 0; i < size; i++)
{
arr1[i] = rand() % 20;
cout << arr1[i] << " ";
}
cout << endl << endl;
cout << "Array 2: ";
for (int j = 0; j < size; j++)
{
arr2[j] = rand() % 20;
cout << arr2[j] << " ";
}
cout << endl << endl;
for (int i = 0; i < size; i++)
{
cout << arr1[i] << " " << arr2[i]<<" ";
}
cout << endl << endl;
}
void task215()
{
int students[25], number;
cout << "Height of 25 students is:\n";
for (int i = 0; i < 25; i++)
{
students[i] = rand() % 31 + 160;
}
for (int k = 0; k < 25; k++)
{
for (int j = 0; j < 25; j++)
{
if (students[j] < students[j + 1])
swap(students[j], students[j + 1]);
}
switch (k)
{
case 24:
for (int l = 0; l < 25; l++)
cout << students[l] << " ";
break;
}
}
tryagain:
cout << "\nEnter number of a student who has to be excluded (numeration from 0)\n";
cin >> number;
if (number >= 0 && number < 25)
for (int i = 0; i < 24; i++)
{
if (i == number)
{
for (int a = number; a < 24; a++)
{
cout << students[a + 1] << " ";
}
i = 25;
}
else cout << students[i] << " ";
}
else
{
cout << "Incorrect number";
goto tryagain;
}
cout << endl << endl;
}
int main()
{int a;
while (true)
{
cout << "Numbers of tasks are 214 226 215\n";
cin >> a;
cout << endl;
switch (a)
{
case 214:
task214();
break;
case 226:
task226();
break;
case 215:
task215();
break;
case 0:
return(0);
break;
default:
cout << "Incorrect number, try again" << endl;
break;
}