Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 making a hollow asterisks box
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
junkpro11




PostPosted: Sun Apr 25, 2004 8:34 pm   Post subject: making a hollow asterisks box

im a noob at turing...im prob the worst in class cuz logic isnt my stong suit.and i took programming to learn sth different. can anyone help me how to make a hollow asterisk box with number of stars across input
eg. the input is 4
the box would be
****
* *
* *
* *
****

my code doesnt work....it onli makes this
****
**
**
****
code:

var inum : int
put "enter number"
get inum
for row : 1 .. inum
    for column : 1 .. inum
        if column = 1 or column = inum or row = 1 or row = inum then
            put "*" ..
        end if
    end for
    put ""
end for
Sponsor
Sponsor
Sponsor
sponsor
junkpro11




PostPosted: Sun Apr 25, 2004 8:36 pm   Post subject: (No subject)

what the? the boz is supposed to be outlined by asterisks but the inside is supposed to hollow

dunno y the msg appeared funni Embarassed
Delos




PostPosted: Mon Apr 26, 2004 9:49 am   Post subject: (No subject)

Hey, this is easy actually!

Just add an 'else' statement to your if condition.

code:

else
put " "..


It look funny on the board due to some odd space removal thing used...
Flashkicks




PostPosted: Mon Apr 26, 2004 10:34 am   Post subject: (No subject)

I remember having to do this when i was in grade nine! Laughing Rolling Eyes We also had to make a Christmas tree which most the kids had problems with..lol And its funny- i was one of them as well Embarassed Rolling Eyes Laughing
Raugrist




PostPosted: Mon Apr 26, 2004 11:19 am   Post subject: (No subject)

Even easier like this:
code:

var num : int
get num
put repeat ("*", num)
put "*", repeat (" ", num - 2), "*"
put "*", repeat (" ", num - 2), "*"
put "*", repeat (" ", num - 2), "*"
put repeat ("*", num)

Good ol' repeat function.
junkpro11




PostPosted: Mon Apr 26, 2004 8:49 pm   Post subject: (No subject)

thank you everyone! im in gr. 10 but teacher didnt teach us repeat yet... Embarassed

this question is on the hw sheet...to prepare us for the test on wed. u can see im not tat good with programming....lacking logic so ty for helping me!!!!

Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 6 Posts ]
Jump to:   


Style:  
Search: