program minetmax;

uses crt;

const long_tab = 3;
type table = array[1..long_tab] of integer;
	   

procedure saisie(var t:table);
var i,res : integer;
begin	  
   for i:=1 to long_tab do
   begin
      write(i,' ieme element ? : ');
      readln(res);
      t[i]:=res;
   end;
end;

procedure visu(t:table);
var i : integer;
begin 
   write('[');
   for i:=1 to long_tab-1 do
   begin
      write(t[i],' ; ')
   end;
   writeln(t[long_tab],']')
end;



function maxi(t:table):integer;
var i,tmp : integer;
begin	  
   tmp := t[1];
   for i:=2 to long_tab do
      if t[i]>tmp then tmp:=t[i];
   maxi:= tmp
end;


procedure minmax_naif(t:table);
var min_tmp, max_tmp, i	: integer;
begin			
   min_tmp:=t[1];
   max_tmp:=t[1];
   for i:=2 to long_tab do
   begin
      if t[i]>max_tmp then max_tmp:=t[i];
      if t[i]<min_tmp then min_tmp:=t[i];
   end;
   writeln('mini : ', min_tmp);
   writeln('maxi : ', max_tmp)
end;

procedure minmax_sioux(L:table);
var min_tmp, max_tmp, i,k : integer;
begin			  
   if long_tab mod 2 = 0 then
   begin
      if L[1]<L[2] then
      begin
	 min_tmp := L[1];
	 max_tmp := L[2];
      end
      else
      begin
	 min_tmp := L[2];
	 max_tmp := L[1]
      end;
      for k:=0 to ((long_tab DIV 2) - 2) do
      begin
	 i:=2*k+3;
	 if L[i]>L[i+1] then
	 begin
	    if min_tmp>L[i+1] then min_tmp := L[i+1];
	    if max_tmp<L[i]   then max_tmp := L[i];
	 end
	 else
	 begin
	    if min_tmp>L[i]   then min_tmp := L[i];
	    if max_tmp<L[i+1] then max_tmp := L[i+1];
	 end
      end
   end
   else
   begin
      min_tmp := L[1] ;
      max_tmp := L[1] ;
      for k:=0 to ((long_tab - 1) DIV 2) - 1 do
      begin
	 i:=2*k+2;
	 if L[i]>L[i+1] then
	 begin
	    if min_tmp>L[i+1] then min_tmp := L[i+1];
	    if max_tmp<L[i]   then max_tmp := L[i];
	 end
	 else
	 begin
	    if min_tmp>L[i]   then min_tmp := L[i];
	    if max_tmp<L[i+1] then max_tmp := L[i+1];
	 end
      end
   end ;
   writeln('mini2 : ',min_tmp);
   writeln('maxi2 : ',max_tmp)
end;

var t1 : table;
	  
begin
   clrscr;
   saisie(t1);
   readln;
   visu(t1);
   readln;
   writeln('maxi de tab : ',maxi(t1));
   readln;
   minmax_naif(t1);
   readln;
   minmax_sioux(t1);
   readln;
end.