Head LELY D.B PRATIWI 1311100012: Contoh pascal yang lain

Contoh pascal yang lain

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.


  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

0 komentar:

Posting Komentar

ENJOY IT ^^

Read more: Cara Membuat Teks Berjalan di Tab dan Navbar Atas | Mas Bugie [dot] com http://www.masbugie.com/2010/04/cara-membuat-teks-berjalan-di-tab-dan.html#ixzz1iYEVcfQi