I have this array which i want to check on 4 in a row (the game). I can do it with hundreds of if else but how can I do it in a loop? Is this even possible? This is my code. Thanks in advance!
int array[][] = {{0, 1, 1, 1, 1, 0, 0},
{0, 0, 0, 1, 0, 1, 1},
{0, 0, 0, 1, 0, 1, 1},
{0, 1, 1, 0, 1, 0, 1},
{1, 0, 0, 1, 0, 1, 1},
{1, 0, 0, 1, 0, 1, 0}};
for (int rows = 0; rows < 6; rows++) {
for(int columns = 0; columns < 7; columns++) {
System.out.print(array[rows][columns] + " ");
}
System.out.println();
}
if (array[0][0] == 0) {
if(array[0][1] == 0) {
if (array[0][2] == 0) {
if (array[0][3] == 0) {
System.out.println("Connect Four!");
}
}
}
}