Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Mar 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Four consecutive pattern program

    Hi all! I'm trying to make a program in Java that does the following:

    The user first enters number of rows and columns for a "table". Then a two dimensional array is created using the amount of rows and columns for each dimension respectively. This array is then filled with numbers. For the time being, I am generating random numbers from 0 to 9 to fill the array. Up to this point, I'm having no problems.

    Now, here's the good part. After filling the array, the program is supposed to tell you if there are any four consecutive same numbers in the array, be it horizontally, vertically or diagonally. I'm having a hard time finding a logic that could work for this program, but every time I think of something it doesn't work. Recently I made a console TicTacToe game in Java, and I assume that the logic for this program is similar to the one I used in the game, but the difference is that the TicTacToe array is 3X3 constant, plus you only have two characters to check: "X" and "O". Whereas in this program, you can have any number, and any size of array.

    Any help that you can provide me will be greatly appreciated, as I've kept trying to find an answer to this but have been unsuccessful.

  • #2
    New to the CF scene
    Join Date
    Mar 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I've managed to do the main diagonal in the middle for both cases (/ and \) however I still can't find a way to do the diagonals above and below the main diagonals.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •