background image

program zad1; 

uses crt; 

const n=10; 

var 

tab:array [1..n] of integer; 

i,max,min,poz_min,poz_max:integer; 

begin 

randomize; 

 

for i:=1 to n do 

begin 

tab[i]:=random(10); 

writeln(tab[i]); 

end; 

 

max:=tab[1]; 

min:=tab[1]; 

 

for i:=2 to n do 

begin 

if max<tab[i] then 

begin 

max:=tab[i]; 

poz_max:=i; 

end; 

 

if min>tab[i] then 

background image

begin 

min:=tab[i]; 

poz_min:=i; 

end; 

end; 

 

i:=tab[poz_min]; 

tab[poz_min]:=tab[poz_max]; 

tab[poz_max]:=i; 

writeln('Po zamianie'); 

 

for i:=1 to n do writeln (tab[i]); 

 

readln; 

end.