untuk membuat gambar anak panah bintang menggunakan delphi

contoh :

*

*

*     *    *

*     *     *     *

*     *    *

*

*

syntax
procedure TForm1.Button1Click(Sender: TObject);
var
i,n,j : integer;
s: string;
begin
n:=strtoint(edit1.text);
listbox1.clear;
for i := 1 to n do
begin
for j := 1 to i do
begin
if (i=j) or ((i-j) >=4) then
s:=s+’*’
else
s:=s+’ ‘;
end;

listbox1.items.add(s);
s:=’ ‘;
end;
end;
for i := n-1 downto 1 do
begin
for j := 1 to i do
begin
if (i=j) or ((i-j) >=4) then
s:=s+’*’
else
s:=s+’ ‘;
end;

listbox1.items.add(s);
s:=’ ‘;
end;
end;
semoga berhasil

Advertisements