Vous êtes sur la page 1sur 7

infoatlps.jimdo.

com 1
program sab;
uses wincrt;
var
ch:string;

procedure saisie(var fch:string);


begin
repeat
writeln('Donner chaine non vide et de longueur impaire:');
readln(fch);
until (length(fch)<>0) and (length(fch) mod 2=1);
end;

procedure sablier(fch:string);
var
l,i,j:integer;
cch:string;
begin
l:=length(fch);
for i:=1 to l div 2 +1 do
begin
cch:='';
for j:=i to l+1-i do
cch:=cch+fch[j];
writeln(cch:l-i+1);
end;
for i:=l div 2 downto 1 do
begin
cch:='';
for j:=i to l-i+1 do
cch:=cch+fch[j];
writeln(cch:l-i+1);
end;
end;

begin
saisie(ch);
sablier(ch);
end.

infoatlps.jimdo.com 2
infoatlps.jimdo.com 3
Program minimum;
uses wincrt;
Type tab = array [1..20] of integer;
Var
T:tab;
n,m:integer;
Procedure saisie(var T:tab; var n:integer);
var
i:integer;
begin
repeat
writeln('Donnez la taille du tableau N avec 5<N<20');
readln(n);
until N in [6..19];
writeln('Remplissez le tableau de ',n,' entiers positifs');
for i:=1 to n do
repeat
writeln('Donner T[',i,' ] = ');
readln(T[i]);
until T[i]>=0;
end;
Procedure min(T:tab; var m,n:integer);
var indi,indj,k:integer;
begin
repeat
writeln('Donner indi et indj telque : 0<indi<indj<=N ');
write('ind_i = ');
readln(indi);
write('ind_j = ');
readln(indj);
until (indi in [1..indj]) and (indj in [indi+1..n]);
m:=T[indi];
for k:=indi+1 to indj do
if T[k]<m then m:=T[k];
writeln('Le Minimum est : ',m);
end;
Procedure affiche(T:tab; m,n:integer);
var i:integer;
begin
writeln('Les multiples de ',m,' sont : ');
for i:=1 to n do
if (T[i] mod m = 0) and (T[i]<>m) then
writeln(T[i],' ');
end;
begin
saisie(T,n);
min(T,m,n);
affiche(T,m,n);
end.

infoatlps.jimdo.com 4
infoatlps.jimdo.com 5
Program tri;
uses wincrt;
type
tab = array [1..19] of integer;
var
t,r:tab;
n:integer;

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


var
j,i:integer;
verif:boolean;
begin
repeat
writeln('Tapez la taille du tableau T télque 5<N<20 :');
readln(n);
until n in [6..19];

writeln('Remplir le tableau T par ',n,' entiers distincts :');


Write('Donner T[1] = ');
readln(t[1]);
for i:=2 to n do
repeat
write('Donner T[',i,'] = ');
readln(T[i]);
verif:=true;
for j:=1 to i-1 do
if t[j]=t[i] then verif:=false;
until (t[i]>=0) and (verif);

end;

function position(t:tab;x,n:integer):integer;
var
j,i:integer;
begin
j:=1;
for i:=1 to n do
if t[i]<x then
j:=j+1;
position:=j;
end;

procedure tritab (var R:tab;T:tab;n:integer);


var
i:integer;
begin
for i:=1 to n do
r[position(t,t[i],n)]:=t[i];
end;

infoatlps.jimdo.com 6
procedure affiche (t:tab;n:integer);
var
i:integer;
begin
for i:=1 to n do
write(t[i],' | ');
writeln;
end;

begin
saisie(t,n);
tritab(r,t,n);
affiche(t,n);
affiche(r,n);
end.

infoatlps.jimdo.com 7