Thread: vertical, horizontal and diagonal arrays

  1. #1
    Unregistered
    Guest

    vertical, horizontal and diagonal arrays

    using an array, how can i check if there is a certain number of 'chips' in a row, horizontal or diagonal. i know that there are a bunch a for loops. its cause this is bearly my first programming class and we just went over this like 4 days ago and he just went over regular arrays like a[5] and like 1/2 a class on a[5][5] so im totally lost. it will be totally appreciated. PLEASE help me. i cant get it to work.

    for example:

    a[5][5];

    ( ) ( ) ( ) ( ) ( )
    ( ) ( ) ( ) ( ) ( )
    ( ) ( ) ( ) ( ) ( )
    ( ) ( ) ( ) ( ) ( )
    (o) (o) (o) (o) ( )
    this is a winner

    ( ) ( ) ( ) ( ) ( )
    (o) ( ) ( ) ( ) ( )
    (o) ( ) ( ) ( ) ( )
    (o) ( ) ( ) ( ) ( )
    (o) ( ) ( ) ( ) ( )
    this is a winner

    ( ) ( ) ( ) ( ) ( )
    ( ) ( ) ( ) (o) ( )
    ( ) ( ) (o) ( ) ( )
    ( ) (o) ( ) ( ) ( )
    (o) ( ) ( ) ( ) ( )
    this is a winner

    ( ) ( ) ( ) ( ) ( )
    ( ) (o) ( ) ( ) ( )
    ( ) ( ) (o) ( ) ( )
    ( ) ( ) ( ) (o) ( )
    ( ) ( ) ( ) ( ) (o)
    this is a winner

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    It's basic math. If you are at XY coordinate, to check to the left, it's X-1, to the right, it's X+1, above, Y-1, below, Y+1, diagonal is just a combination of those moves.

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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 2D diagonal counter
    By poopiepantz2525 in forum C Programming
    Replies: 4
    Last Post: 05-01-2008, 06:53 PM
  2. help with 3D tic-tac-toe diagonal checking
    By tunerfreak in forum C++ Programming
    Replies: 3
    Last Post: 04-01-2006, 10:14 PM
  3. help with arrays and loops
    By jdiazj1 in forum C Programming
    Replies: 4
    Last Post: 11-24-2001, 04:28 PM