public class Triangles
{
public static int checkPyramid(int[][] board , int row , int col)
{
boolean check = true;
if (board[row][col] == 1)
{
while (board[row + 1][col + 1] != 0 && board.length > row && board[row + 1].length > col && check)
{
for(int i = 0 ; i < board[row][col] + 2 ; i ++)
{
if (board[row + 1][col - 1] == board[row + 1][col + i])
{}
else
check = false;
}
row ++ ;
col -- ;
}
}
else
row = -1 ;
return row ;
}
public void getMat(int[][] newArr)
{
for(int i = 0; i < newArr.length; i++)
{
for(int j = 0; j < newArr[i].length; j++)
{
if(checkPyramid(newArr,i,j) != -1)
{
System.out.print("[(" + j + "," + i + ")]");
System.out.print(checkPyramid(newArr,j,i));
System.out.println();
}
}
}
}
}
Comments