include stdio include stdlib include locale define define PN printf in

 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
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
#define N 5
#define PN printf("\n")
int main(void)
{int mass[N],i,tmp,max,otr;
setlocale(LC_ALL, "Russian");
printf("Ââåäèòå ìàññèâ:\n");
//input
for(i=0;i<N;i++)
scanf("%d", mass+i);
PN;
//job
max=0;
otr=0;
for(i=otr+1;i<N;i++)
if(mass[i]<0 && mass[i]>mass[otr])
otr=i;
for(max=0,i=1;i<N;i++)
if(mass[i]>mass[max])
max=i;
tmp=mass[max];
mass[max]=mass[otr];
mass[otr]=tmp;
PN;
printf("Íó ó ìåíÿ ïîëó÷èëîñü ñëåäóþùåå.... :\n");
PN;
//out
for(i=0;i<N;i++)
printf("%d ", mass[i]);
PN;
PN;
system("PAUSE");
return 0;
}