Selasa, 20 Desember 2011

Lanjutkan menuju contoh Program Pascal bagian 5




CONTOH PROGRAM BINTANG PIRAMIDA
uses wincrt;
var
a,b,c,d:integer;
begin
write('masukkan jumlah baris bintang yang akan ditampilkan:');readln(a);
for b:= 1 to a do
begin
for c:= a downto b do
write(' ');
for d:= 1 to b+b-1 do
write('*');
writeln;
end;
end.
tampilan :


CONTOH PROGRAM BERBENTUK BINTANG


program bintang_segitiga;
uses wincrt;
var
a,b,c: integer;

begin
readln(a);
for b:=a downto 1 do
begin
for c:=1 to a do
write('*');
writeln;
a:=a-1;
end;
end.
 Output:
Masukkan jumlah baris 4
****
***
**
*

PROGRAM BINTANG_BELAH_KETUPAT

uses wincrt;
var
N,i,j,k,max,min : integer;
begin
gotoXY(30,0); writeln('"program belah ketupat"');
gotoXY(30,2); writeln('----------------------------------------');
writeln;
write ('Masukkan Batas : ');readln(N);
writeln;
begin
for i:=1 to (n*2+1) do
begin
write;
end;
begin
for i := 1 to N do
begin
for k := (N-1) downto i do
begin
write (' ');
end;

for j:= 1 to i do
begin
write('* ');
end;
begin
for j:=(i-1) downto 1 do
write('* ');
end;
writeln(' ');
end;
begin
for i := (N-1) downto 1 do
begin
for k := (N-1) downto i do
begin
write (' ');
end;

for j := i downto 1 do
begin
write ('* ');
end;
begin
for j := 1 to (i-1) do
write('* ');
end;
writeln(' ');
end;
end;
end;
end;
end.

CONTOH PROGRAM BERBENTUK BINTANG RATA KIRI

program bintang_segitiga;
uses wincrt;
var i,n,j:integer;
begin
write('masukkan n= ');readln(n);
for i:=n downto 1 do
begin
for j:=1 to n do
begin
if (j<i) then write (' ')
else
write('*');
write(' ');
end;
writeln(' ');
end;
end.
Output:
masukkan jumlah bintang terbawah : 3
    *
  **
***

0 komentar:

:)) :)] ;)) ;;) :D ;) :p :(( :) :( :X =(( :-o :-/ :-* :| 8-} ~x( :-t b-( :-L x( =))

Posting Komentar