Guest User

very simple sort

a guest
Apr 9th, 2019
88
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. program deb;
  2. uses crt;
  3. const n=100;
  4. var a: array[1..n] of integer;
  5.     b, i,j:integer;
  6.     cont : boolean = true;
  7. begin
  8. randomize;
  9.  
  10. writeln ('new masiv');
  11. for i:=1 to n do
  12. begin
  13.     a[i]:=Random(100);
  14.     write(a[i], ' ');
  15. end;
  16. writeln;
  17.  
  18. while cont do
  19. begin
  20.     cont := false;
  21.     for j:=1 to n-1 do
  22.         if a[j] > a[j+1] then
  23.         begin
  24.             b := a[j];
  25.             a[j]:= a[j+1];
  26.             a[j+1]:=b;
  27.             cont := true;
  28.             (*
  29.             write(' swap,' ,a[j] ,'<>' ,a[j+1]);
  30.             writeln();
  31.             *)
  32.         end;
  33. end;
  34.  
  35. writeln('sort masiv');
  36. for i:=1 to n do
  37.     write(a[i], ' ');
  38.    
  39. end.
RAW Paste Data