Check out the Pastebin Gadgets Shop. We have thousands of fun, geeky & affordable gadgets on sale :-)Want more features on Pastebin? Sign Up, it's FREE!
tweet

# test3

By: a guest on Feb 26th, 2012  |  syntax: Pascal  |  size: 1.25 KB  |  views: 37  |  expires: Never
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}
6.
7.
9.
10.
12.
13.
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
32.     outer:=1;
33.     while (outer<=size) and (outer<=maximum) do
34.       begin
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.%
clone this paste RAW Paste Data
Top