Input : D A N I E L
Output :
L E I N A D
L E I N A
L E I N
L E I
L E
L
Programnya:
Program segitiga_terbalik_awal;
Uses Forms;
{$apptype console}
Var nm:string; a,b,p:integer;
Begin
Write(‘masukin nama= ‘);readln(nm);
P:=length(nm);
For a:=1 to p do
Begin
For b:=p downto a do
Begin
Write(copy(nm,b,1),’ ‘);
End;
Writeln;
End;
Readln;
End.
Input : DANIEL
Output :
L E I N A D
E I N A D
I N A D
N A D
A D
D
Programnya:
Program segitiga_terbalik_akhir;
Uses Forms;
{$apptype console}
Var nm:string; a,b,p:integer;
Begin
Write(‘masukin nama= ‘);readln(nm);
P:=length(nm);
For a:=p downto 1 do
Begin
For b:=a downto 1 do
Begin
Write(copy(nm,b,1),’ ‘);
End;
Writeln;
End;
Readln;
End.
Input : Gonzaga
Output :
A
G A
A G A
Z A G A
N Z A G A
O N Z A G A
G O N Z A G A
Programnya :
Program segitiga_gonzaga;
Uses forms;
{$apptype console}
Var nm : string; a,b,p:integer;
Begin
Write(‘masukin nama= ‘);readln(nm);
P:=length(nm);
For a:=p downto 1 do
Begin
For b:=a to p do
Begin
Write(copy(nm,b,1),’ ‘);
End;
Writeln;
End;
Readln;
End.
Input : GONZAGA
Output :
A
A G
A G A
A G A Z
A G A Z N
A G A Z N O
A G A Z N O G
Programnya :
Program segitiga_agaznog;
Uses forms;
{$apptype console}
Var nm : string; a,b,p:integer;
Begin
Write(‘masukin nama= ‘);readln(nm);
P:=length(nm);
For a:=p downto 1 do
Begin
For b:=p downto a do
Begin
Write(copy(nm,b,1),’ ‘);
End;
Writeln;
End;
Readln;
End.
Input : Riska atau Reno
Output :
GANJIL
--------------
R I S K A
I S K A
S K A
K A
A
K A
S K A
I S K A
R I S K A
Atau
GENAP
--------------
O
N O
E N O
R E N O
E N O
N O
O
Programnya:
program pengulangan_maha_bertingkat_banyak;
uses forms;
{$apptype console}
var nm:string; a,b,p:integer;
begin
write('nama= ');readln(nm);
p:=length(nm);
if p mod 2=0 then
writeln(‘GENAP’);
writeln(‘------------------‘);
begin
for a:=p downto 1 do
begin
for b:=a to p do
begin
write(copy(nm,b,1),' ');
end;
writeln;
end;
for a:=p-2 to p do
begin
for b:=a to p do
begin
write(copy(nm,b,1),' ');
end;
writeln;
end;
end
else
begin
writeln(‘GANJIL’);
writeln(‘----------------------‘);
for a:=1 to p do
begin
for b:=a to p do
begin
write(copy(nm,b,1),' ');
end;
writeln;
end;
for a:=p downto 2 do
begin
for b:=a-1 to p do
begin
write(copy(nm,b,1),' ');
end;
writeln;
end;
end;
readln;
end.
Versi Thomas
program PR_komputer;
uses forms;
{$apptype console}
var nm,mn : string;
i1,i2,l : integer;
begin
clrscr;
write('Nama : ');readln(nm);
l := length(nm);
writeln;
for i1 := l downto 1 do
begin
mn := mn + copy(nm,i1,1);
end;
if l mod 2 = 0 then
begin
writeln('GENAP');
writeln('-----');
for i1 := 1 to l do
begin
for i2 := i1 downto 1 do
begin
write(copy(mn,i2,1),' ');
end;
writeln;
end;
for i1 := 2 to l do
begin
for i2 := i1 to l do
begin
write(copy(nm,i2,1),' ');
end;
writeln;
end;
end
else
if l mod 2 = 1 then
begin
writeln('GANJIL');
writeln('------');
for i1 := 1 to l do
begin
for i2 := i1 to l do
begin
write(copy(nm,i2,1),' ');
end;
writeln;
end;
for i1 := 2 to l do
begin
for i2 := i1 downto 1 do
begin
write(copy(mn,i2,1),' ');
end;
writeln;
end;
end;
readln;
end.
1 komentar:
terkait dengan penerapan borland delphi, bisa diunduh artikel berikut http://repository.gunadarma.ac.id/bitstream/123456789/1330/1/21107495.pdf
Posting Komentar