Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Compile and Execute Pascal Online

Program start;
var respone :integer;
procedure BubbleSort( var a: array of TItemBubbleSort );
 
implementation
 
procedure swap( var a, b:TItemBubbleSort );
var
  temp : TItemBubbleSort;
begin
  temp := a;
  a := b;
  b := temp;
end;
 
 
procedure BubbleSort( var a: array of TItemBubbleSort );
var
  n, newn, i:integer;
begin
  n := high( a );
  repeat
    newn := 0;
    for i := 1 to n   do
      begin
        if a[ i - 1 ] > a[ i ] then
          begin
            swap( a[ i - 1 ], a[ i ]);
            newn := i ;
          end;
      end ;
    n := newn;
  until n = 0;
end;
  writeln('1. Bubble Sort');
  writeln('2. Insertion Sort');
  writeln('3. Merge Sort');
  writeln('4. Quick Sort');
  writeln('5. Exit');
  readln(response);
while response <> 5 do
 begin
  writeln('1. Bubble Sort');
  writeln('2. Insertion Sort');
  writeln('3. Merge Sort');
  writeln('4. Quick Sort');
  writeln('5. Exit');
  readln(response);
  case response of
     '1': Bubble;
     '2': Insertion;
     '3': Merge;
     '4': Quick;
     '5': writeln('Thanks for using this program!')
  end;
 end;
end.

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.