program Ex_11_s4;
uses wincrt;
type
tab=array[1..25] of integer;
var t:tab;
i,n:integer;
procedure saisie(var t:tab; var n:integer);
begin repeat
writeln('Donner n entre 5 et 25 :');
readln(n);
until n in [5..25];
for i:=1 to n do repeat
writeln('Donner un entier d''au moins trois chiffres T ',i);
readln(t[i]);
until t[i]>=100;
end;
procedure Affiche(t:tab;n:integer);
begin
for i:=1 to n do write(t[i],' | ');
end;
procedure zigzag(t:tab;n:integer);
var
ch:string;
test,testc,testd:boolean;
j:integer;
begin WRITELN;
writeln('Les nombres ZigZag Sont:');
For i:=1 to n do begin
str(t[i],ch);
j:=2;
if ord(ch[j])>ord(ch[j-1]) then begin
testc:=true;
testd:=false;
end;
if ord(ch[j])<ord(ch[j-1]) then begin
testc:=false;
testd:=true;
end;
repeat inc(j);
test:=false;
if (testc) and (ord(CH[j])<ord(ch[j-1])) then begin
test:=true;
testc:=false;
testd:=true;
end;
if (testd) and (ord(CH[j])>ord(ch[j-1])) then begin
test:=true;
testc:=true;
testd:=false;
end;
until (test=false) or (j=length(ch));
if (test) then writeln(t[i]);
end; end;
begin
saisie(t,n);
affiche(t,n);
zigzag(t,n);
end.