Advertisement
Guest User

Untitled

a guest
Aug 29th, 2014
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.80 KB | None | 0 0
  1. public class Homework1 {
  2.  
  3.         public static boolean isConsecutiveFour(int[][] values){
  4.            
  5.             for(int r = 0; r < values.length; r++){
  6.                
  7.                 for(int c = 0; c < values[r].length; c++){
  8.                    
  9.                     int position = values[r][c];
  10.                    
  11.                     if((values[r][c + 1] == position) && (values[r][c + 2] == position) && (values[r][c + 3] == position))
  12.                         return true;
  13.                    
  14.                     if((values[r+1][c] == position) && (values[r+2][c] == position) && (values[r+3][c] == position))
  15.                         return true;
  16.                    
  17.                     if((values[r+1][c+1] == position) && (values[r+2][c+2] == position) && (values[r+3][c+3] == position))
  18.                         return true;
  19.                    
  20.                     if((values[r+1][c-1] == position) && (values[r+2][c-2] == position) && (values[r+3][c-3] == position))
  21.                         return true;
  22.            
  23.                 }
  24.             }
  25.            
  26.             return false;
  27.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement