Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

test3

By: a guest on Feb 26th, 2012  |  syntax: Pascal  |  size: 1.25 KB  |  views: 37  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. program bubblesort;
  2. const maximum=20;
  3. var x:array[1..maximum] of integer;
  4. {array to sort}
  5. {Read unsorted numbers
  6.  
  7.  
  8. Read u numbers
  9.  
  10.  
  11. Read unsorted nu
  12.  
  13.  
  14.           Read unsort}
  15. outer,inner,size:integer;
  16. procedure order(var x,y:integer);
  17. var h:integer;
  18. begin
  19.     if x>y then
  20.       begin
  21.         h:=x;
  22.         x:=y;
  23.         y:=h
  24.       end
  25. end;
  26. begin
  27.     {Read unsorted numbers}
  28.     {Read u numbers}
  29.     {Read unsorted nu}
  30.     {Read unsort}
  31.     read(size);
  32.     outer:=1;
  33.     while (outer<=size) and (outer<=maximum) do
  34.       begin
  35.         read(x[outer]);
  36.         outer:=outer+1
  37.       end;
  38.       {Sort the array}
  39.       outer:=1;
  40.       while outer<size do
  41.         begin
  42.           inner:=1;
  43.           while inner<=size-outer do
  44.             begin
  45.               order(x[inner],x[inner+1]);
  46.               inner:=inner+1
  47.             end;
  48.             outer:=outer+1
  49.         end;
  50.         if (true) then
  51.           writeln;
  52.           {Print the sorted array}
  53.           outer:=1;
  54.           while outer<=size do
  55.             begin
  56.               write(x[outer]);
  57.               outer:=outer+1
  58.             end;
  59.            
  60. end.%