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
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.
Tidak ada komentar:
Posting Komentar