Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-13-2011, 04:58 AM   PM User | #1
plasmastar
New to the CF scene

 
Join Date: Mar 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
plasmastar is an unknown quantity at this point
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.
plasmastar is offline   Reply With Quote
Old 03-14-2011, 12:54 AM   PM User | #2
plasmastar
New to the CF scene

 
Join Date: Mar 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
plasmastar is an unknown quantity at this point
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.
plasmastar is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:55 AM.


Advertisement
Log in to turn off these ads.