We help IT Professionals succeed at work.

Rectangle X, Y.

Libberachi asked
on
Medium Priority
302 Views
Last Modified: 2010-04-16
The program receives two numbers X, Y, it will writ to sqreen a rectangle of \$ according to the numbers entered.
what I can not get right is the spaces between the two
column. I can only get:   \$\$\$\$\$\$
\$
\$
\$
\$\$\$\$\$\$
Thanks for your help.

ad.
Comment
Watch Question

View Solution Only

Commented:
Can you be a little more specific? Do you need a procedure that draws rectangles in textmode?

Commented:
Need to writ a program using integer numbers x, y, and while loops, the program shall be able to writ to sqreen (Alt + F5).
Thats all.

PS. A procedure that draws at text mode is welcom too.

ad.
Commented:
This question looks like homework... But nevermind.

Those procedures does not check X,Y.
The first (and simpler) procedure draws a filled rectangle.
The second procedure draws the outlines of the rectangle.

procedure WriteRectangle1(X,Y:integer);
const
Ch='\$';
var
a,b:integer;
begin;
for a:=1 to X do begin;
for b:=1 to Y do write(Ch);
writeln;
end;
end;

procedure DrawRectangle2(X,Y:integer);
const
Ch='\$';
var
a,b:integer;
begin;
for b:=1 to Y do write(Ch);
writeln;
for a:=1 to X do begin;
write(Ch);
for b:=1 to (Y-2) do write(' ');
writeln(Ch);
end;
for b:=1 to Y do write(Ch);
writeln;
end;

Not the solution you were looking for? Getting a personalized solution is easy.

Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

• View three pieces of content (articles, solutions, posts, and videos)
• Ask the experts questions (counted toward content limit)
• Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the