/**
* Function Name: checkRight
* @param board char[][]
* @return count (int)
* Inside the function
* 1.using single loop to check the left diagnol are same X/O
*
*/
public static int checkRight(char[][] board){
int count=0;
for(int i=0; i<board.length; i++){
if(board[i][2-i]=='X'){
count++;
}
else if(board[i][2-i]=='O'){
count--;
}
}
if(count==3|| count == -3){
return count;
}
else{
count =0;
}
return count;
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter