Pascal triangle in pascal


gw punya contoh program buat segitiga pascal, bisa dicoba..

hehe..
kalo masih ada yang kurang, mungkin bisa ditambahin ato dikoreksi lah kalo ada kesalahan..


--------------------------------------------------------
program PascalTriangle;
uses
crt;
var
i,j,n: integer;
x: array[1..100,1..100] of integer;
begin

clrscr;
write('Banyak baris: '); readln (n);

for i:=1 to n do

for j:=1 to n do

begin

if j=1 then x[i,j]:=1

else if j=i then x[i,j]:=1

else x[i,j]:=x[i-1,j-1]+x[i-1,j];
end;

for i:=1 to n do
begin
gotoxy(40-3*i,2+i);

for j:=1 to i do
write(x[i,j]:6);

end;

readln;
end.

-----------------------------------------------------

  • support our brother..

    support our brother..

    ShoutMix chat widget