1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
program ex1SR3;
uses wincrt;
type tab= array[2..100] of integer;
var
n:integer;
R,t:tab;
function taille : integer;
var x:integer;
begin
repeat
writeln('Entrer la taille du tableau SVP [2..50]');
read(x);
until x in [2..50] ;
taille := x;
end;
procedure autocharge (n:integer;var t :tab);
var
i:integer;
begin
randomize;
for i:= 1 to n do
begin
t[i] := random(100);
end;
end;
procedure affiche (n:integer; t:tab);
var
i:integer;
begin
for i:= 1 to n do
begin
writeln('La case N°',i,'= ',t[i]);
end;
end;
procedure compter (n:integer; var t:tab);
var
i,j,cpt:integer;
begin
for i:=1 to n do
begin
cpt:= 0 ; j:=i+1;
repeat
if t[j]<t[i] then
cpt := cpt+1;
until t[j]>t[i];
R[cpt]:=t[j];
end;
end;
{Programme principale}
BEGIN
n:=taille ;
autocharge(n,t);
affiche(n,t);
compter(n,t);
affiche(n,R);
end. |
Partager