contoh1
program segitiga;
uses crt;
var i,j,n:integer;
begin
clrscr;
write('Masukkan jumlah baris = ');readln(n);
for i:=1 to n do
begin
for j:=1 to i do
write('*');
writeln;
end;
readln;
end.
contoh2
program segitiga;
uses crt;
var jlh_brs,jlh,baris,spasi,bintang,n:integer;
begin
clrscr;
write('Masukkan jumlah baris=');readln(n);
jlh_brs:=n;
jlh:=jlh_brs*2-1;
for baris:=1 to jlh_brs do
begin
for spasi:=1 to baris do
write(' ');
for bintang:=1 to jlh do
write('*');
writeln;
jlh:=jlh-2;
end;
readln;
end.
program segitiga;
uses crt;
var i,j,n:integer;
begin
clrscr;
write('Masukkan jumlah baris = ');readln(n);
for i:=1 to n do
begin
for j:=1 to i do
write('*');
writeln;
end;
readln;
end.
contoh2
program segitiga;
uses crt;
var jlh_brs,jlh,baris,spasi,bintang,n:integer;
begin
clrscr;
write('Masukkan jumlah baris=');readln(n);
jlh_brs:=n;
jlh:=jlh_brs*2-1;
for baris:=1 to jlh_brs do
begin
for spasi:=1 to baris do
write(' ');
for bintang:=1 to jlh do
write('*');
writeln;
jlh:=jlh-2;
end;
readln;
end.
No comments:
Post a Comment