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);
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.
Ini dia Segitiga Pascalnya
Deret fibonaci
Bagi yang mencari program pasal deret fibonaci ini dia jawabannya!
program fibonaci;
uses wincrt;
procedure FIBO(key : string; k : integer);
var
x,y,z,i,n:longint;
baris : word;
begin
x:=1;
y:=1;
writeln(' *', key, '*');
for baris:=1 to k do
begin
writeln;
end;
write(' Masukkan banyaknya bilangan fibonacci = ');readln(n);
write(x, ' ');
write(y, ' ');
for i:=1 to n-2 do
begin
z:=x+y;
x:=y;
y:=z;
write(z, ' ');
end;
end;
begin
FIBO('Simple Fibonacci', 2);
end.
Ternyata Pascal gak Cuma buat rumus
Ini contohnya
program persegi;
uses wincrt;
procedure
gb (p,l:integer);
var
i,j:integer;
begin
for i:=1 to p do
begin
for j:=1 to l do
begin
if ((i=1)or(i=p)or(j=1)or(j=l))then
write ('*')
else write (' ');
end;
writeln;
end;
end;
var
x,y:integer;
begin
write ('panjang yang diinginkan= '); readln (y);
write ('lebar yang diinginkan= '); readln (x);
writeln ('ini dia perseginya');
gb (x,y);
end.
0 komentar:
Posting Komentar