Advertisement
sapitando

Bubble sort em Pascal 1.

Jul 31st, 2016
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.58 KB | None | 0 0
  1. Program Bubble_sort;
  2. uses crt;
  3.  
  4. const MAXNRO = 10;
  5.  
  6. var Nro : array [1..MAXNRO] of extended;
  7.     NroAux : extended;
  8.     C1, C2 : word;
  9.  
  10. begin
  11. Nro[1] := 10;
  12. Nro[2] := 5;
  13. Nro[3] := 3;
  14. Nro[4] := 6;
  15. Nro[5] := 4;
  16. Nro[6] := 9;
  17. Nro[7] := 8;
  18. Nro[8] := 2;
  19. Nro[9] := 7;
  20. Nro[10] := 1;
  21.  
  22. for C1 := 1 to MAXNRO do
  23.  for C2 := 2 to MAXNRO do
  24.   if Nro[C2 - 1] > Nro[C2]
  25.   then begin
  26.         NroAux := Nro[C2 - 1];
  27.         Nro[C2 - 1] := Nro[C2];
  28.         Nro[C2] := NroAux;
  29.        end;
  30.  
  31. clrscr;
  32. for C1 := 1 to MAXNRO do
  33.  writeln(C1 : 3,' : ',Nro[C1] : 2 : 2);
  34. readkey;
  35.  
  36. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement