Pascal

Moderators: None (Apply to moderate this forum)
Number of threads: 4095
Number of posts: 14004

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Need your help on pascal Posted by af_juventus on 14 Mar 2007 at 5:14 AM
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.

Report
Re: Need your help on pascal Posted by zibadian on 14 Mar 2007 at 5:57 AM
: 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.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.