Program Bubble Sort dengan Menggunakan Array (Pascal)

Contoh Program Bubble Sort array dengan Pascal


Program bubble_sort_dengan_menggunakan_array;

Uses wincrt ;

Var A : array [1..100] of integer;

 n,i,j,jum : integer;

Begin

 Clrscr;

 Write ('Mau  isi  berapa  data  acak  (integer)=');

 readln (n);

 For i:=1 To n Do

Begin

  Write ('data ke',i,':');  readln(A[i]);

End;

For i : = 1 To n -1 Do

Begin

For j : = i To n Do

Begin

If A [j] < A[i] Then

Begin

    Jum : = A[j];

    A[j] : = A[i];

    A[i] : = jum

End; End; End;

 Writeln ;

Writeln( 'Hasil Sort' );

For i : = 1 To n Do

Write(' ',A[i]);

Readln; End.
Program Bubble Sort dengan Menggunakan Array (Pascal) Program Bubble Sort dengan Menggunakan Array (Pascal) Reviewed by ReyGumay on May 17, 2015 Rating: 5

No comments:

Powered by Blogger.