int main() { cout << "Enter size of array : "; int size; cin >> size; cout << endl; int *arr = new int[size]; for (int i = 0; i < size; i++) { cin >> arr[i]; } cout << "" << endl;
int Largest(arr[0]), largest_index;
for (int i = 0; i < size; i++) { if (Largest < arr[i]) Largest = arr[i]; } for (int i = 0; i < size; i++) { if (arr[i] == Largest) largest_index = i; }
int Middle(arr[0]), middle_index;
for (int i = 0; i < size; i++) { if (i != largest_index) { if (Middle < arr[i]) Middle = arr[i]; } } for (int i = 0; i < size; i++) { if (arr[i] == Middle) middle_index = i; } for (int i = 0; i < size; i++) { if (i < largest_index && i > middle_index) arr[i] = 0; } cout << "" << endl; for (int i = 0; i < size; i++) cout << arr[i] << endl; _getch(); return 0;
using namespace std;
int main()
{
int s, i;
cout << "s = ";
cin >> s;
double a[s], m1, m2;
int m1i, m2i, f, t;
/* Заполнение */
for (i = 0; i < s; i++)
{
cout << i << ':';
cin >> a[i];
}
/* Первый максимум */
m1i = 0;
m1 = a[m1i];
for (i = 1; i < s; i++)
{
if (a[i] > m1)
{
m1 = a[i];
m1i = i;
}
}
/* Второй максимум */
m2i = 0;
m2 = a[m2i];
for (i = 1; i < s; i++)
{
if (i == m1i) continue;
if (a[i] > m2)
{
m2 = a[i];
m2i = i;
}
}
/* Порядок итерации */
if (m1 > m2)
{
f = m2i;
t = m1i;
}
else
{
f = m1i;
t = m2i;
}
for (i = f + 1; i < t; i++)
{
a[i] = 0;
}
for (i = 0; i < s; i++)
{
cout << a[i] << ' ';
}
return 0;
}
#include <conio.h>
using namespace std;
int main()
{
cout << "Enter size of array : ";
int size; cin >> size;
cout << endl;
int *arr = new int[size];
for (int i = 0; i < size; i++)
{
cin >> arr[i];
}
cout << "" << endl;
int Largest(arr[0]), largest_index;
for (int i = 0; i < size; i++)
{
if (Largest < arr[i])
Largest = arr[i];
}
for (int i = 0; i < size; i++)
{
if (arr[i] == Largest)
largest_index = i;
}
int Middle(arr[0]), middle_index;
for (int i = 0; i < size; i++)
{
if (i != largest_index)
{ if (Middle < arr[i])
Middle = arr[i];
}
}
for (int i = 0; i < size; i++)
{
if (arr[i] == Middle)
middle_index = i;
}
for (int i = 0; i < size; i++)
{
if (i < largest_index && i > middle_index)
arr[i] = 0;
}
cout << "" << endl;
for (int i = 0; i < size; i++)
cout << arr[i] << endl;
_getch();
return 0;