: Hi all, I'm newbie in Pascal. I need your help.
: I want to make pascal program with output like this :
:
Insert value n : 5 (as example)
: Output :
:
: 1234512345
: 1234 2345
: 123 345
: 12 45
: 1 5
: 1 5
: 12 45
: 123 345
: 1234 2345
: 1234512345
:
: I have try making program like this :
:
:
var
: a,b,c,d,e:integer;
: begin
: clrscr;
: write('Insert value n : '); readln(a);
: writeln;
: for b:=a downto 1 do
: begin
: for c:=1 to b do
: write(c);
: writeln
: end;
:
: for d:=1 to a do
: begin
: for e:=1 to d do
: write(e);
: writeln;
: end;
: readln;
: end.
:
: But the output when i insert value n = 5 :
:
12345
: 1234
: 123
: 12
: 1
: 1
: 12
: 123
: 1234
: 12345
:
: I'm so confused what code that i must add.
: Please help me!! Thanx very much.
:
:
Here's the first part:
for LineIndex := 1 to 5 do
begin
// Write first 1/2 of line
for i := 1 to 5 do
if 6-i >= LineIndex then
write(i)
else
write(' ');
// Write second 1/2 of line
for i := 1 to 5 do
if i >= LineIndex then
write(i)
else
write(' ');
writeln;
end;
I leave the second part up to you.