Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program Bubble_sort;
- uses crt;
- const MAXNRO = 10;
- var Nro : array [1..MAXNRO] of extended;
- NroAux : extended;
- C1, C2 : word;
- begin
- Nro[1] := 10;
- Nro[2] := 5;
- Nro[3] := 3;
- Nro[4] := 1;
- Nro[5] := 4;
- Nro[6] := 9;
- Nro[7] := 8;
- Nro[8] := 2;
- Nro[9] := 7;
- Nro[10] := 1;
- for C1 := 2 to MAXNRO do
- if Nro[C1 - 1] > Nro[C1]
- then begin
- C2 := C1;
- while (C2 > 1) and (Nro[C2 - 1] > Nro[C2]) do
- begin
- NroAux := Nro[C2 - 1];
- Nro[C2 - 1] := Nro[C2];
- Nro[C2] := NroAux;
- dec(C2);
- end;
- end;
- clrscr;
- for C1 := 1 to MAXNRO do
- writeln(C1 : 3,' : ',Nro[C1] : 2 : 2);
- readkey;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement