- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
#include "pch.h"
#include <iostream>
using namespace std;
void p(int a[], int &h )
{
int i = 0;
int max = 0;
int counter = 1;
while (counter < h)
{
if (a[counter] > a[max])
{
max = counter;
}
counter = counter + 1;
}
int min = 0;
int counter2 = 1;
while (counter < h)
{
if (a[counter] < a[min])
{
min = counter;
}
counter = counter + 1;
}
int kol, kol2;
if (max > min)
{
if (max != min)
{
kol = max - min - 1;
i = min + 1;
cout << "Kolichestvo elementov mezdu imin i imax: " << kol << endl;
}
else
{
cout << "Kolichestvo elementov mezdu imin i imax: 0" << endl;
}
}
else
{
if (max != min)
{
kol2 = min - max - 1;
i = max + 1;
cout << "Kolichestvo elementov mezdu imin i imax: " << kol2 << endl;
}
else
{
cout << "Kolichestvo elementov mezdu imin i imax: 0" << endl;
}
}
int sum = 0;
while (i < max)
{
sum = sum + a[i];
i++;
}
cout << "Summa elementov mezdu imin i imax: " << sum << endl;
}
int main()
{
int h;
cout << "Vvedite razmer massiva: ";
cin >> h;
int *a = new int[h];
for (int i = 0; i < h; i++)
cin >> a[i];
p(a, h);
delete[] a;
return 0;
}
ugk 26.11.2018 21:56 # 0
UPPERCASE 26.11.2018 23:03 # 0
БУДЬ ЗДОРОВ, СОСИ БОЛЬШОЙ.
guest8 29.11.2018 02:10 # −999
crestoblyad 30.11.2018 16:58 # 0