Problem with this?

This is a discussion on Problem with this? within the C Programming forums, part of the General Programming Boards category; How do you do this Code: * * * * * * * * * * * * * * ...

  1. #1
    Registered User
    Join Date
    Jul 2002
    Posts
    8

    Question Problem with this?

    How do you do this

    Code:
    * * * *
     * * *
    * * * *
     * * *
    * * * *
    how many for loops do I need, basicaly I just need the formula rather than the whole answer.



    Code tags added by Hammer

  2. #2
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,386
    For 2 dimensional figures, most people would use two loops. One for the x-direction and one for the y-direction.

  3. #3
    Dev
    Dev is offline
    Registered User Dev's Avatar
    Join Date
    Mar 2003
    Posts
    59
    Whatever is the number of rows , that should be taken as your main FOR loop. And try to analyse the pattern of what is required.

    See there are alternatively 4 and 3 stars. So set one boolean variable to do that thing.

  4. #4
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,386
    >See there are alternatively 4 and 3 stars. So set one boolean variable to do that thing.

    More easy would be to use the modulo-operator. At the even lines there are 3 stars, at the odd lines there are 4 stars.

  5. #5
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    >>how many for loops do I need,
    None. Just printf() the output in the desired format directly. One line of code will do it. (oh, don't tell me, you have to use loops )
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  6. #6
    Dev
    Dev is offline
    Registered User Dev's Avatar
    Join Date
    Mar 2003
    Posts
    59
    >>>>how many for loops do I need,
    None. Just printf() the output in the desired format directly. One line of code will do it. (oh, don't tell me, you have to use loops ),
    What a logic.

  7. #7
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    You can do this with one loop, and the box size would be sizable (ie: you input the size). It's just a matter of providing the right conditions in the loop.

    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help understanding a problem
    By dnguyen1022 in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2009, 04:21 PM
  2. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 10:22 AM
  3. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  4. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  5. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21