Vous êtes sur la page 1sur 4

program examen_8h;

uses wincrt;
type
tab = array[1..15] of string;
tab2 = array[1..15] of integer;
var t,de,qu:tab; n:integer;deg:tab2;

function verif(ch:string):boolean;
var i:integer; ok:boolean;
begin
i:=1; ok:=true;

while (i<=length(ch)) and(ok = true) do


if ch[i] in ['0'..'9'] then
i:= i+1
else
ok:= false;
verif:= ok;
end;

procedure saisie(var t: tab; var n:integer);


var i:integer;
begin

repeat
writeln('Entrer Le nombre d''appartements :');
readln(n);
until n in [5..15];

for i:= 1 to n do
repeat
writeln('Entrer l''élément n°:',i);
readln(t[i]);
until (length(t[i])=5)and (verif(t[i]));
end;

procedure affiche(var de,qu:tab;t:tab;var deg:tab2;n:integer);


var k,i,x,e,max:integer; st:string;
begin
for i:= 1 to n do
begin
de[i]:= copy(t[i],1,2);
qu[i]:= copy(t[i],3,3);
end;

for i:= 1 to n do
begin
val(de[i],x,e);
deg[i]:=x;
end;
writeln;
max := deg[1];

for i:= 1 to n do
if deg[i]>=max then
begin
max:= deg[i];
end;

writeln('Le plus grand degré d''urgence est ',max);


writeln('Les appartements concernés sont:');

for i:=1 to n do
begin
if deg[i] = max then
writeln(i,' avec une quantité de fumée = ',qu[i]);
end;
end;

begin
saisie(t,n);
affiche(de,qu,t,deg,n);
end.
program examen_14h;
uses wincrt;
type tab = array[1..100] of integer;
var t,t1,t2,t3: tab;n:integer;

procedure saisie(var n:integer; var t:tab);


var i:integer;
begin
repeat
writeln('entrer la taille du tableau : ');
readln(n);
until n in [5..20];

for i:= 1 to n do
begin
write('T[',i,'] = ');
readln(t[i]);
end;
end;

procedure affiche (t:tab;var t1,t2,t3:tab;n:integer);


var i,j,k,l,s:integer;
begin
i:=2; j:=0; k:=0;

repeat
if t[i]<=T[1] then
begin
j:=j+1;
t1[j]:=t[i];
i:=i+1;
end
else
begin
k:=k+1;
t2[k]:=t[i];
i:=i+1;
end;
until i>=n+1 ;
l:=0; i:=1;

repeat
l:=l+1;
t3[l]:= t1[i];
i:=i+1;
until (i=j+1);
l:=l+1;
t3[l]:= t[1];
s:=1;

repeat
l:=l+1;
t3[l]:=t2[s];
s:=s+1;
until s = k+1;

writeln;

write('le tableau T segmenté:');


for i:= 1 to n do
write(' | ',t3[i]);
end;

begin
saisie(n,t);
affiche(t,t1,t2,t3,n);
end.