Author |
Message |
Fubar
|
Posted: Sun May 15, 2005 1:03 pm Post subject: A little help |
|
|
I figured it out thanks Cervantes. |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Cervantes
![](http://compsci.ca/v3/uploads/user_avatars/1023105758475ab2e040bde.jpg)
|
Posted: Sun May 15, 2005 2:17 pm Post subject: (No subject) |
|
|
Welcome to compsci.ca.
Your question sounds like homework to me. Know that we don't do homework for you. I hope that's not what you're asking. To help you, though:
You'll definately need to know for loops. Getting the top and bottom lines of the z should be easy using for loops (actually, it's easier without for loops and with using repeat). Getting the middle line is a little harder. Use a for loop to go down from the top of the z to the bottom and the number of spaces to put before the '*' is directly related to how far down the z you are.
Hopefully you understood that. If not... well, it's really not that hard. Thinking about it for a minute or two should do the trick.
Oh, and if you don't know for loops, here's a link to the tutorial. |
|
|
|
|
![](images/spacer.gif) |
Fubar
|
Posted: Sun May 15, 2005 2:42 pm Post subject: (No subject) |
|
|
well basically i couldn't get the middle part of the 'z'.
code: |
var size : int
get size
if (size < 3 and size > 25) then
put "Invalid input"
elsif (size >= 3 and size <= 25) then
cls
for top : 1 .. size
put "*" ..
end for
% for decreasing mid : size - 2 .. 1
% put " ", "*"
% end for
for bottom : 1 .. size
put "*" ..
end for
end if
|
still working on it.
thanks,
Fubar |
|
|
|
|
![](images/spacer.gif) |
sockoo
![](http://www.competitiveness.org/ezimagecatalogue/catalogue/variations/149-100x100.jpg)
|
Posted: Sun May 15, 2005 3:27 pm Post subject: (No subject) |
|
|
i modified ur code to what i beleive you want .. lemme know
code: |
var size : int
get size
if (size < 3 and size > 25) then
put "Invalid input"
elsif (size >= 3 and size <= 25) then
cls
for top : 1 .. size
put "*" ..
end for
locate(2,1) % MODIFIED (added in)
put"*" % MODIFIED (added in)
for bottom : 1 .. size
put "*" ..
end for
end if
|
|
|
|
|
|
![](images/spacer.gif) |
Fubar
|
Posted: Sun May 15, 2005 3:35 pm Post subject: (No subject) |
|
|
That's not what i meant ^^. Say the user inputs 3, it would draw this:
***
^*^
***
so it looks like a 'z'. |
|
|
|
|
![](images/spacer.gif) |
Notoroge
![](http://i6.photobucket.com/albums/y230/notoroge/DUCK.jpg)
|
Posted: Sun May 15, 2005 3:49 pm Post subject: (No subject) |
|
|
code: | var size, count : int
count := 2
get size
cls
put repeat ("*", size)
loop
for i : 1 .. (size - count)
put " " ..
end for
put "*"
count := count + 1
exit when count = size
end loop
put repeat ("*", size) |
You're welcome. |
|
|
|
|
![](images/spacer.gif) |
Notoroge
![](http://i6.photobucket.com/albums/y230/notoroge/DUCK.jpg)
|
Posted: Sun May 15, 2005 3:52 pm Post subject: (No subject) |
|
|
Wow sockoo, You're really over complicating it. If it works, it works though.
Update: Haha, what a way to delete your post just in time. ![Very Happy Very Happy](images/smiles/icon_biggrin.gif) |
|
|
|
|
![](images/spacer.gif) |
Fubar
|
Posted: Sun May 15, 2005 4:07 pm Post subject: (No subject) |
|
|
Notorage it doesn't work. this is how it's supposed to look:
See how it's suppose to allign. |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Cervantes
![](http://compsci.ca/v3/uploads/user_avatars/1023105758475ab2e040bde.jpg)
|
Posted: Sun May 15, 2005 4:07 pm Post subject: (No subject) |
|
|
That's the connection I was getting at, Notoroge, between size and the position of the star in the diagonal line.
Now that you've given him the answer... let's improve it.
Turing: |
var size : int
get size
put repeat ("*", size )
for i : 2 .. size - 1
put repeat (" ", size - i ), "*"
end for
put repeat ("*", size )
|
There's no need to use a loop like you did, when we know how many times we want it to execute and when we want a counter variable. Just use a for loop! |
|
|
|
|
![](images/spacer.gif) |
Notoroge
![](http://i6.photobucket.com/albums/y230/notoroge/DUCK.jpg)
|
Posted: Sun May 15, 2005 4:09 pm Post subject: (No subject) |
|
|
Dude, I updated it. Look at it. It works perfectly. Ah! I should have typed that in the Update as well. Look at it though. IT WORKS! ![Sad Sad](http://compsci.ca/v3/images/smiles/icon_sad.gif) |
|
|
|
|
![](images/spacer.gif) |
sockoo
![](http://www.competitiveness.org/ezimagecatalogue/catalogue/variations/149-100x100.jpg)
|
Posted: Sun May 15, 2005 7:00 pm Post subject: (No subject) |
|
|
Notoroge wrote: Wow sockoo, You're really over complicating it. ![Confused Confused](http://compsci.ca/v3/images/smiles/icon_confused.gif) If it works, it works though.
Update: Haha, what a way to delete your post just in time. ![Very Happy Very Happy](images/smiles/icon_biggrin.gif)
lol yes i deleted my post as i saw ur's works perfectly ![Razz Razz](images/smiles/icon_razz.gif) |
|
|
|
|
![](images/spacer.gif) |
|