Esercizi in pascal

Materie:Appunti
Categoria:Informatica
Download:38
Data:25.05.2000
Numero di pagine:1
Formato di file:.txt (File di testo)
Download   Anteprima
esercizi-pascal_4.zip (Dimensione: 0.69 Kb)
trucheck.it_esercizi-in-pascal.txt     678 Bytes
readme.txt     59 Bytes


Testo

program bubble_sort; (*2 mar 98*)
const n=10;
var a:array[1..n] of integer;
i,j,aux :integer;
begin
for i:= 1 to n do
readln(a[i]);
for i:= (n-1) downto 1 do
for j:= 1 to i do
if (a[j] > a[j+1]) then
begin
aux:= a[j] ;
a[j]:=a[j+1];
a[j+1]:=aux;
end;
for i:= 1 to n do
writeln (a[i]);
end. program bubble_sort; (*2 mar 98*)
const n=10;
var a:array[1..n] of integer;
i,j,aux :integer;
bo : boolean;
begin
bo:= true;
for i:= 1 to n do
readln(a[i]);
for i:= (n-1) downto 1 do
for j:= 1 to i do
if (a[j] > a[j+1]) then
begin
bo:=false;
aux:= a[j] ;
a[j]:=a[j+1];
a[j+1]:=aux;
end;
if (bo=true) then
writeln ('il vettore Љ gi… ordinato')
else for i:= 1 to n do
writeln (a[i]);
end.

Esempio