Thread: 2D Array

  1. #1
    Registered User
    Join Date
    Apr 2016
    Posts
    1

    2D Array

    i would like to ask on how to write a code for a 3*3 2d array, the requirement is initialized zero to whole array, and the value of the middle array should be set to 1 which is array[2][2]='1', u can choose to either move left, right, top or down for the array value '1', After every single move have been made,the array will be printed to the screen, whereverthere is a 1 in the array, display an asterisk, Wherever there is a zero, display a blank.

    _ _ _
    _ 1 _
    _ _ _

    move to right

    _ _ _
    _ * 1
    _ _ _

  2. #2
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    Before you write code, you need to come up with a plan. Break the problem down into discrete steps to develop the necessary logic. Then start developing your code gradually, adding a little bit of code, compiling, and testing, before moving on to the next piece of code. A development process

    I would suggest first declaring and initializing your array, and printing it. When you get this working, it will not only verify your array is correctly initialized, but you also have the "printing" code all done.

    Keep gradually building up your program in this manner. If you get stuck along the way, post your code (in code tags) with an explanation of where you're stuck.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 12
    Last Post: 07-31-2013, 12:15 AM
  2. Replies: 10
    Last Post: 09-09-2012, 02:29 PM
  3. Replies: 2
    Last Post: 03-20-2012, 08:41 AM
  4. Replies: 9
    Last Post: 08-23-2010, 02:31 PM
  5. Replies: 6
    Last Post: 11-09-2006, 03:28 AM

Tags for this Thread