Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package check;
- public class Check
- {
- public static void main(String[] args)
- {
- String input = "1,0,0,0,0;0,1,0,0,0;0,1,0,0,0;0,0,1,0,0;0,0,0,0,0";
- String[] input1 = input.split(";");
- String[][] input2 = new String[input1.length][];
- int mark1 = 0;
- int mark2 = 0;
- int check = 1;
- for(int x = 0; x < input1.length; x++)
- {
- input2[x] = input1[x].split(",");
- }
- if(input1.length == 1)
- {
- for(int x = 0; x < input1.length; x++)
- {
- if(input1[x].equals("1"))
- check = 1;
- }
- }
- else
- {
- for(int y = 0; y<input1.length; y++)
- {
- for(int x = 0; x < input2[y].length; x++)
- {
- if(input2[y][x].equals("1") && y == 0)
- mark1 = x;
- else if(input2[y][x].equals("1"))
- mark2 = x;
- }
- if((mark2 -1 == mark1 || mark2 == mark1 || mark2 + 1 == mark1) && input1[y].contains("1") && check == 1)
- check = 1;
- else
- check = 0;
- if(y == 2)
- {
- mark1 = mark2;
- }
- }
- }
- if(check == 1)
- System.out.println("yes");
- else
- System.out.println("no");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment