CONTOH PROGRAM SEGITIGA SATU KE SEPULUH
program segitiga_satu_ke_sepuluh;
uses wincrt;
var
n,i,j:integer;
begin
n:=1;
for i:=1 to 4 do
begin
for j:=1 to i do
begin
write(n,' ');
n:=n+1;
end;
writeln(' ');
end;
end.
CONTOH PROGRAM SEGITIGA LIMA KEATAS
program segitiga_lima_keatas;
uses wincrt;
var i,j:integer;
begin
for i:=1 to 5 do
begin
for j:=1 to i do
write(j,' ');
writeln;
end;
end.
CONTOH PROGRAM SEGITIGA LIMA KEBAWAH
program segitiga_lima_kebawah;
uses wincrt;
var i,j:integer;
begin
for i:=5 downto 1 do
begin
for j:=1 to i do
write(j,' ');
writeln;
end;
end.
CONTOH PROGRAM SEGITIGA MUNDUR KEBELAKANG
program segitiga_angka_mundur;
uses wincrt;
var
tulisan:string[10];
i,j,posisi:integer;
begin
tulisan:='543210';
j:=length(tulisan);
posisi:=j;
for i:=1 to j do
begin
delete(tulisan,posisi,1);
WRITELN(TULISAN);
posisi:=j-i;
end;
end.
CONTOH PROGRAM SEGITIGA PERKALIAN
program segitiga_pascal_perkalian_sendiri;
uses wincrt;
var i,j,n: integer;k:longint;
begin
readln (n);
for i:=1 to n do
begin
k:=1;
for j:= 1 to i do
begin
k:=k*i;
write(k); write(' ');
end;
writeln;
end;
end.
CONTOH PROGRAM SEGITIGA PASCAL
program segitiga_pascal;
uses wincrt;
var input,i,j:word; isi:array[0..20,0..21] of word;
begin
writeln('Masukkan berapa tingkat segitiga pascal !');
readln(input);
writeln;
writeln(1);
isi[0,1]:=1;
for i:=1 to input do
begin
for j:=1 to i+1 do
begin
isi[i,j]:=isi[i-1,j]+isi[i-1,j-1];
write(isi[i,j],' ');
end;
writeln;
end;
end.
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar