for(j=0;j<=5;j++)
if(a[j] ==y && b[j] ==y && c[j] ==y && d[j] ==y)
win++;
else if(b[j] ==y && c[j] ==y && d[j] ==y && e[j] ==y)
win++;
else if(c[j] ==y && d[j] ==y && e[j] ==y && f[j] ==y)
win++;
for(j=0;j<=3;j++)
if(a[j] ==y && b[j+1] ==y && c[j+2] ==y && d[j+3] ==y)
win++;
else if (b[j] ==y && c[j+1] ==y && d[j+2] ==y && e[j+3] ==y)
win++;
else if (c[j] ==y && d[j+1] ==y && e[j+2] ==y && f[j+3] ==y)
win++;
if (win!=1){
if(play%2==0){do{
Scanner sc = new Scanner(System.in);
System.out.print("Player 1 type a column (0-6) or 9 to quit current game : ");
k = sc.nextInt();
if (k<0 || k>6)
System.out.println("Range of column should be 0 to 6!");
if (f[k]!=0)
System.out.println("Column " + k + " is full!");
}while(k <0 || k>6 || f[k]!=0);
y=1;}
else{do{
Scanner sc = new Scanner(System.in);
System.out.print("Player 2 type a column (0-6) or 9 to quit current game : ");
k = sc.nextInt();
if (k<0 || k>6)
System.out.println("Range of column should be 0 to 6!");
if (f[k]!=0)
System.out.println("Column " + k + " is full!");
}while(k<0 || k >6 || f[k]!=0);
y=2;}
if(a[k] == 0)
a[k] = y;
else if (b[k] == 0)
b[k] = y;
else if (c[k] == 0)
c[k] = y;
else if (d[k] == 0)
d[k] = y;
else if (e[k] == 0)
e[k] = y;
else if (f[k] == 0)
f[k] = y;
play++;}
}while(win != 1);
System.out.println("Player"+y+" win this game!");
if(y==2)
player2++;
else
player1++;
Scanner sc = new Scanner(System.in);
System.out.print("Do you want to continue (Yes=1, No=0)?");
k = sc.nextInt();
}while(k ==1);
System.out.println("Player1 wins " +player1 +" game.");
System.out.println("Player2 wins " +player2 +" game.");
if (player1==player2)
System.out.println("No final winner.");
else if(player2>player1)
System.out.println("The final winner is player2.");
else
System.out.println("The final winner is player1.");
System.out.println("Bye Bye!");
}
}