#include <iostream>
#include <ctime>
using namespace std;
void Max(int*& arr, int& size, int& maxi)
{
int max = 1;
for (int i = 0; i < size; i++)
if (arr[i] > max)
maxi = i;
break;
}
void Min(int*& arr, int& size, int& mini)
int min = 10000;
if (arr[i] < min)
min = arr[i];
mini = i;
void main()
srand(time(0));
setlocale(LC_ALL, "ru");
int Sum = 0;
bool after = 0;
int Maxi = 1;
int Mini = 1;
int size = 1;
cout << "Укажите размер массива - ";
cin >> size;
cout << endl;
int* arr = new int[size];
arr[i] = 1 + rand() % 40;
cout << arr[i] << " ";
Max(arr, size, Maxi);
Min(arr, size, Mini);
if (Maxi > Mini)
bool after = 1;
if (after)
cout << "\n\nМаксимальный эл-т встречается после минимального\n";
for (int i = Mini + 1; i < Maxi; i++)
Sum += arr[i];
for (int i = Maxi + 1; i < Mini; i++)
delete[]arr;
cout << "\nСумма = " << Sum << endl;
Объяснение:
class Finder:
def __init__(self):
self.current_range = range(1, 101)
def condition(self, user_select):
if user_select == '1':
return True
elif user_select == '2':
self.current_range = range(int(self.current_half + self.current_range.start), self.current_range.stop)
return False
elif user_select == '3':
self.current_range = range(self.current_range.start, int(self.current_half + self.current_range.start))
@property
def current_half(self) -> int:
return int((self.current_range.stop - self.current_range.start) / 2)
finder = Finder()
while True:
user_select = input(f'Это {finder.current_half + finder.current_range.start}?\n')
result = finder.condition(user_select)
if result:
break
#include <iostream>
#include <ctime>
using namespace std;
void Max(int*& arr, int& size, int& maxi)
{
int max = 1;
for (int i = 0; i < size; i++)
{
if (arr[i] > max)
{
maxi = i;
break;
}
}
}
void Min(int*& arr, int& size, int& mini)
{
int min = 10000;
for (int i = 0; i < size; i++)
{
if (arr[i] < min)
{
min = arr[i];
mini = i;
}
}
}
void main()
{
srand(time(0));
setlocale(LC_ALL, "ru");
int Sum = 0;
bool after = 0;
int Maxi = 1;
int Mini = 1;
int size = 1;
cout << "Укажите размер массива - ";
cin >> size;
cout << endl;
int* arr = new int[size];
for (int i = 0; i < size; i++)
{
arr[i] = 1 + rand() % 40;
cout << arr[i] << " ";
}
Max(arr, size, Maxi);
Min(arr, size, Mini);
if (Maxi > Mini)
bool after = 1;
if (after)
{
cout << "\n\nМаксимальный эл-т встречается после минимального\n";
for (int i = Mini + 1; i < Maxi; i++)
{
Sum += arr[i];
}
}
for (int i = Maxi + 1; i < Mini; i++)
{
Sum += arr[i];
}
delete[]arr;
cout << "\nСумма = " << Sum << endl;
}
Объяснение:
class Finder:
def __init__(self):
self.current_range = range(1, 101)
def condition(self, user_select):
if user_select == '1':
return True
elif user_select == '2':
self.current_range = range(int(self.current_half + self.current_range.start), self.current_range.stop)
return False
elif user_select == '3':
self.current_range = range(self.current_range.start, int(self.current_half + self.current_range.start))
return False
@property
def current_half(self) -> int:
return int((self.current_range.stop - self.current_range.start) / 2)
finder = Finder()
while True:
user_select = input(f'Это {finder.current_half + finder.current_range.start}?\n')
result = finder.condition(user_select)
if result:
break