Minggu, 25 Maret 2012

 Tugas Struktur Data 3

procedure faktorial(var f,jumlah:real);
var j:integer;
begin
jumlah:=1; j:=1;
while j<=f do
 begin jumlah:=jumlah*j;
       j:=j+1;
 end;
end;

begin
writeln('=======================');
writeln('    masukkan angka     ');
writeln('=======================');
writeln;
write('x=');readln(n);
write('y=');readln(r);
nr:=n-r;
faktorial(n,f1);
faktorial(nr,f2);
faktorial(r,f3);
f4:=f2*f3;
c:=f1/f4;
writeln;
writeln('hasil kombinasi =',c:4:0);
writeln('=======================');
end.

inilah hasil program di atas
 



Minggu, 11 Maret 2012

TUGAS STRUKTUR DATA 2

program pengembalian_uang_belanja;
uses wincrt;

var
   kode,nama,brg:string[50];
   hrg,jumlahbrg,uang,tot,byr: longint;
   barang:array[1..50]of integer;

begin
clrscr;
write('Nama Pembeli : ');readln(nama);
writeln;
writeln(' PEMBELIAN ');
writeln('  ----------------------------------');
write('  Kode Barang : ');readln(kode);
write('  Nama Barang : ');readln(brg);
write('  Harga Satuan Barang : ');readln(hrg);
write('  Jumlah : ');readln(jumlahbrg);
writeln;
tot:=hrg*jumlahbrg;

clrscr;
writeln('Balis dwi wahyudi');
writeln('111221098');
writeln;
writeln('Nama Pembeli : ',nama);
writeln('========================================================================');
write('| Kode barang | ');
write('Nama Barang | ');
write('satuan(Rp) | ' );
write('jumlah | ' );
write('harga n jumlah(Rp) |');
writeln;
writeln('========================================================================');
begin
writeln;
write('    ',kode,'      ');
write('   ',brg:10,'    ');
write(' ',hrg:10,'    ');
write('   ',jumlahbrg,'    ');
write(tot:10);
end;
writeln;
writeln('========================================================================');
  write('Uang Pembayaran : ');readln(byr);
  uang:=byr-tot;
  writeln;
  writeln('Uang Kembalian');
writeln('------------------------------------------------------------------------');

  if uang div 100000 > 0 then begin
    writeln(uang div 100000, ' lembar seratus ribuan');
    uang := uang mod 100000;
  end;

  if uang div 50000 > 0 then begin
    writeln(uang div 50000, ' lembar lima puluh ribuan');
    uang := uang mod 50000;
  end;

  if uang div 20000 > 0 then begin
    writeln(uang div 20000, ' lembar dua puluh ribuan');
    uang := uang mod 20000;
  end;

  if uang div 10000 > 0 then begin
    writeln(uang div 10000, ' lembar sepuluh ribuan');
    uang := uang mod 10000;
  end;

  if uang div 5000 > 0 then begin
    writeln(uang div 5000, ' lembar lima ribuan');
    uang := uang mod 5000;
  end;

  if uang div 1000 > 0 then begin
    writeln(uang div 1000, ' lembar ribuan');
    uang := uang mod 1000;
  end;

  if uang div 500 > 0 then begin
    writeln(uang div 500, ' lembar lima ratusan');
    uang := uang mod 500;
  end;

  if uang div 100 > 0 then begin
    writeln(uang div 100, ' ratusan');
    uang := uang mod 100;
  end;

  if uang div 50 > 0 then begin
    writeln(uang div 50, ' limapuluhan');
    uang := uang mod 50;
  end;

  if uang > 0 then begin
    writeln(uang, ' satuan');
  end;

  writeln('=======================================================================');

end.



inilah hasil program di atas

Minggu, 04 Maret 2012

TUGAS PERTAMA STRUKTUR DATA

Jawaban tugas struktur data no.1
 
program matriks_identitas;
uses WinCrt;
var
mat:array[1..5,1..5]of integer;
a,b:integer;
begin
writeln('matriks identitas : ');
writeln;
  for a:=1 to 5 do
  begin
    for b:=1 to 5 do
    begin
      mat[a,b]:=0;
      if a+b=6 then mat[a,b]:=1;
      write (mat[a,b]:3);
    end;
   writeln;
  end;
  writeln;
  writeln('sekian dan terima kasih');
end.

Inilah tampilan setelah program dijalankan.



Jawaban tugas struktur data no. 2

program perkalian_matriks;
uses wincrt;
var
   a,b,c : array [1..5,1..5] of integer;
   d,e,f,n,m,p : integer;
begin
     clrscr;
     writeln('NAMA : BALIS DWI WAHYUDI');
     writeln('NIM  : 111221098');
     writeln('=======================');
     writeln('matriks A');
     write('jumlah Baris : '); readln(n);
     write('jumlah Kolom : '); readln(m);
     writeln;
     writeln('matriks B');
     writeln('jumlah Baris : ',m);
     write('jumlah Kolom : '); readln(p);
     writeln('=======================');
     for d:=1 to n do
     for e:=1 to m do
     begin
          write('Elemen A[',d,',',e,'] : ');
          readln(a[d,e]);
     end;
     writeln;
     for d:=1 to m do
     for e:=1 to p do
     begin
          write('Elemen B[',d,',',e,'] : ');
          readln(b[d,e]);
     end;
     for d:=1 to n do
     for e:=1 to p do
     for f:=1 to m do
     c[d,e] := c[d,e] + a[d,f]*b[f,e];
     writeln('=======================');
     writeln('Hasil perkalian Matriks A dengan Matriks B : ');
     Writeln;
     for d:=1 to n do
     begin
          for e:=1 to p do
          write(c[d,e]:4);
     writeln;
     end;
     writeln('sekian dan terima kasih');
     readln;
end.

 Inilah tampilan setelah program dijalankan.