Rabu, 04 Januari 2012

CONTOH PROGRAM SEGITIGA

PROGRAM SEGITIGA

program segitiga_pascal_kombinasi;
uses wincrt;
var   a,b,c,n:integer;

function fkom(n:integer; m:integer): real;
var x,y,z,i: integer;
begin
x:=1; y:=1; z:=1;
for i:=1 to n do x:=x*i;
for i:=1 to m do y:=y*i;
for i:=1 to (n-m) do z:=z*i;
fkom:=x/(y*z);
end;

begin
write('masukkan nilai n = '); readln(n);
if n>=0 then
for a:=0 to n do
    begin
    for b:=n downto a do write('*');
        begin
        for c:=0 to a do write(fkom(a,c):3:0);
        writeln;
        end;
    end;
end.

0 komentar:

Posting Komentar

 
Design Downloaded from Free Blogger Templates | Free Website Templates