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
| program t1;
const n=5;
var truc:array[0..n] of integer;
x,i,j,posmin:integer;
cons:boolean;
begin
for i:=0 to n do
begin
writeln('entrez un valeur:',i);
read(truc[i]);
end;
for i:=0 to n do
begin
posmin:=i;
for j:=i+1 to n do
begin
if truc[j]<truc[i] then
posmin:=j;
end;
x:=truc[posmin];
truc[posmin]:=truc[j];
truc[j]:=truc[i];
truc[i]:=x;
end;
for i:=0 to n do
begin
write(truc[i],' ');
end;
cons:=true;
for i:=0 to n do
begin
if truc[i+1]<>truc[i]+1 then
cons:=false;
end;
if cons=true then
write('les nombres sont tous conscutifs')
else
writeln('les nombres ne sont pas tous conscutifs');
end. |
Partager