Kamis, 03 November 2011

Program Menjumlahkan Pecahan


Program Pecahan;
Uses Wincrt;
Var pmb,pny : array [1..10] of integer;
i,j,n,t1,t2 : integer;
Begin
Writeln('Program Pecahan');
Writeln('===============');
Writeln;
Write('Jumlah Data Pecahan: ');Readln(n);
Writeln;
For i := 1 to n do
Begin
Write('Pembilang ke-',i,' : ');Readln(pmb[i]);
Write('Penyebut ke-',i,' : ');Readln(pny[i]);
End;
Writeln;
Writeln('Pecahan Yang Di Masukkan:');
For i := 1 to n do
Writeln(pmb[i],'/',pny[i]);
For i := 1 to n-1 do
For j := i+1 to n do
Begin
if ((pmb[i]/pny[i])>(pmb[j]/pny[j])) then
Begin
t1:=pmb[i];
t2:=pny[i];
pmb[i]:=pmb[j];
pny[i]:=pny[j];
pmb[j]:=t1;
pny[j]:=t2;
End;
End;
Writeln;
Writeln('Hasilnya: ');
For i := 1 to n do
Writeln(pmb[i],'/',pny[i]);
End.


Output:




Related Articel:

0 komentar:

Posting Komentar

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Affiliate Network Reviews