Листинг include stdio include stdlib define int main void int mas sum

 1
 2
 3
 4
 5
 6
 7
 8
 9
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
Листинг:
#include <stdio.h>
#include <stdlib.h>
#define N 5
int main(void)
{
int mas[N],i,sum=0,min,max,j,b;
//input mass
for(i=0;i<N;i++)
scanf("%d", mas+i);
//min and max
min=mas[0];
max=0;
for(i=0;i<N;i++)
{
if(mas[i]<=min)
{
j=i;
min=mas[i];
}
if(mas[i]>=max)
{
b=i;
max=mas[i];
}
}
//job
if(j>b)
{
for(b++;b<j;b++)
sum+=mas[b];
}
else
{ for(j++;j<b;j++)
sum+=mas[j];
}
//out
printf("\n\n%d\n\n",sum);
system("PAUSE");
return 0;
}