[TP] La position des entiers dans un tableau
Bonsoir tout le monde
J'ai réussi à faire une fonction pour déterminer le plus petit et plus grand entiers dans un tableau.
Je les ai affichés.
Maintenant, il faut que je détermine leur position.
Ma question en Turbo Pascal est comment détermine-t-on la position d'un entier et comment affiche-t-on dans un tableau.
Merci
Cordialement
A bientôt
Position + min max dans tableau
Bonsoir tout le monde
Là plus rien ne va plus il me sort un résultat faux.
Où est l'erreur dans mon code svp?
Voici les fonctions et procédure
Code:
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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
|
function reminmax(minmax:integer):integer;
var i:integer;
begin
B:=mytable[i];
for i:=0 to 10 do
begin
if B > mytable[i] then B:=mytable[i];
end;
reminmax:=B;
A:=mytable[i];
for i:=0 to 10 do
begin
if A < mytable[i] then A:=mytable[i];
end;
reminmax:=A;
end;
function positionminmax(x:integer):integer;
var i:integer;
begin
c:=mytable[i];
for i:=0 to 10 do
begin
if c > mytable[i] then c:=i;
end;
positionminmax:=c;
d:=mytable[i];
for i:=0 to 10 do
begin
if d < mytable[i] then d:=i;
end;
positionminmax:=d;
end;
procedure tableau;
begin
remplir;{Appel procedure remplir avec radomize}
lire;{procedure lire pour lire le tableau}
writeln;
writeln('plus grand ', reminmax(max));
writeln('plus petit ',reminmax(min));
writeln;
writeln('position du plus grand ', positionminmax(max));
writeln('position du plus petit ',positionminmax(min));
end; |
Je tourne bourrique, je ne sais plus quoi faire.
Merci
Cordialement
A bientôt