Sabtu, 24 Maret 2012



 TUGAS 4 KOMBINASI

program faktor_kombinasi;
uses WinCrt;

procedure Fak(Var F,Hasil:integer);
var
i:integer;
begin
     Hasil:=1;
     For i:=2 to F do Hasil:=Hasil*i;
end;

var
R,N,NR,F1,F2,F3:integer;
C:real;

begin
  write('Banyaknya Data      = '); readln(N);
  write('Banyaknya Kombinasi = '); readln(R);

  NR:=N-R;

  Fak(N,F1);
  Fak(NR,F2);
  Fak(R,F3);
 
  C:=F1/(F2*F3);
 
  writeln;
  writeln('Kombinasi Yang Terjadi = ',C:9:0);

end.





Sabtu, 10 Maret 2012


program detail_uang;
uses wincrt;
var
a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z:longint;
begin
write ('berapa uang yang harus di kembalikan');
writeln;
write('total harga =');readln (x);
write('jumlah uang =');readln(y);
z:=y-x;
writeln('uang kembalian anda=',z);

d:=z mod 100000;
p:=z div 100000;

e:=d mod 50000;
q:=d div 50000;

f:=e mod 20000;
r:=e div 20000;

g:=f mod 10000;
s:=f div 10000;

h:=g mod 5000;
t:=g div 5000;

i:=h mod 2000;
u:=h div 2000;

j:=i mod 1000;
v:=i div 1000;

k:=j mod 500;
w:=j div 500;

l:=k mod 200;
x:=k DIV 200;

m:=l mod 100;
y:=l div 100;

n:=m mod 50;
z:=m div 50;


IF p>0 THEN WRITELN('100000    =',p);
IF q>0 THEN WRITELN('50000     =',q);
IF r>0 THEN WRITELN('20000     =',r);
IF s>0 THEN WRITELN('10000     =',s);
IF t>0 THEN WRITELN('5000      =',t);
IF u>0 THEN WRITELN('2000      =',u);
IF v>0 THEN WRITELN('1000      =',v);
IF w>0 THEN WRITELN('500       =',w);
IF x>0 THEN WRITELN('200       =',x);
IF y>0 THEN WRITELN('100       =',y);
IF z>0 THEN WRITELN('50        =',z);

writeln;
writeln('terima kasih ,');




END.

















program detail_uang;

uses wincrt;

var

a,b,c,d,e,f,g,j,k,l,m,n:longint;

begin

write ('nilai a='); readln(a);



c:=a mod 50000;

j:=a div 50000;

d:=c mod 10000;

k:=c div 10000;

e:=d mod 5000;

l:=d div 5000;

f:=e mod 1000;                                                           




m:=e div 1000;

g:=f mod 500;

n:=f div 500;





if j>0then writeln ('50000=',j) else writeln('');

if k>0 then writeln ('10000=',k) else writeln('');

if l>0 then writeln ('5000=',l) else writeln('');

if m>0 then writeln ('1000=',m)else   writeln('');

if n>0then writeln('500=',n)else writeln('');

end.










Sabtu, 03 Maret 2012

PERTEMUAN KE 2 TANGGAL 29 FEBRUARI 2012
SEMESTER 2D
TUGAS 1 :
  • Buat Program Untuk Perkalian Dua Matrix
  • Buat Program Untuk Menampilkan Matrix Identitas Terbalik




  1. Program Pascal Untuk Menghitung Perkalian Dua Matrix

PROGRAM PERKALIAN_MATRIX;
USES WINCRT;

VAR
A,B,C : ARRAY [1..10,1..10] OF INTEGER;
I,J,K,X,Y,Z : INTEGER;


BEGIN
WRITELN('Ukuran  Matrix A');
WRITE('Baris : '); READLN(X);
WRITE('Kolom : '); READLN(Y);
WRITELN;


WRITELN('Ukuran Matrix B');
WRITELN(Baris : ',Y);
WRITE('Kolom : '); READLN(Z);
     WRITELN;

WRITELN ('Elemen Matrix A');
FOR I:=1 TO x DO
FOR j:=1 TO y DO
BEGIN
WRITE('elemen A[',i,',',j,'] : ');READLN(A[I,J]);
END;

WRITELN;


WRITELN ('Elemen Matrix B');
FOR I:=1 TO Y do
FOR J:=1 TO Z do
BEGIN
WRITE('B[',I,',',J,'] : '); READLN(B[I,J]);
END;

FOR I:=1 TO X DO
FOR J:=1 TO Z DO
FOR k:=1 TO Y DO
C[I,J] := C[I,J] + A[I,K]*B[K,J];
WRITELN;
WRITELN;

WRITELN('Hasil Perkalian Matrix A dan Matrix B adalah : ');
WRITELN;

FOR I:=1 TO X DO
BEGIN
FOR J:=1 TO Z DO
WRITE(C[I,J],' ');
WRITELN;
END;
END.


1.2 LAYOUT GAMBAR











 
  1. Program Pascal Untuk Menampilkan Matrix Identitas Terbalik

PROGRAM MATRIX;
USES WINCRT;

VAR
 A,B,C :ARRAY[1..10,1..10] OF INTEGER;
 X,Y,KOL,BAR:INTEGER;

BEGIN

  FOR X:=1 to 5 DO
BEGIN
  FOR Y:=1 to 5 DO
BEGIN
   C[X,Y] := 0;
   IF X+Y=6 THEN C[X,Y]:=1;
   WRITE(C[X,Y]:4);
   END;
   WRITELN;
   END;

END.

2.2 Layout Program