Minggu, 03 Juni 2012

bahasa pemrograman pascal ascending


program  ascending;
uses crt ;
var
         list         : array [1..100] of integer ;
         i, n, j, r   : integer ;
         ch           : char ;
begin
         repeat
         clrscr;
         write('Banyak bilangan acak : ');
         repeat
               gotoxy(40,1);
               clreol;
               readln(n);
         until (n>0) and (n<=100);
         randomize;
         for j := 1 to n do
         begin
              list [j] := random(1000);
              write(list [j] : 5);
              if ( j mod 12 = 0) then writeln;
         end;
         for i := j-1 downto 1 do
         for j := 1 to i do
         if list [j] > list [j+1] then
         begin
              r          := list [j];
              list [j]   := list [j+1];
              list [j+1] := r ;
         end;
         writeln;writeln;
         write('Ascending : ');
         for j := 1 to n do
         begin
              write(list [j] : 5);
         end;
         gotoxy(20,24);
         writeln('Mau ulang lagi? [Y/N] ');
         repeat
               ch := readkey until upcase(ch) in ['Y' , 'N'];
         until upcase (ch) = 'N';
End.

Tidak ada komentar:

Posting Komentar