Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class hw2{
- public static void main(String[] args){
- Scanner scan = new Scanner(System.in);
- int[] a = new int[16];
- //placeholder for arraycopy
- int[] b = new int[16];
- //eating counter
- int f = 0;
- for(int i=0; i<a.length; i++){
- a[i]=scan.nextInt();
- }
- for(int i=0; i<a.length; i++){
- //verticales
- boolean c = a[0]==a[2]&&a[0]==a[4]&&a[0]==a[6]&&a[0]==a[8]&&a[0]==a[10]&&a[0]==a[12]&&a[0]==a[14];
- //horizontales
- boolean d = a[1]==a[3]&&a[1]==a[5]&&a[1]==a[7]&&a[1]==a[9]&&a[1]==a[11]&&a[1]==a[13]&&a[1]==a[15];
- //diagonales
- boolean e = Math.abs(a[2]-a[0])==Math.abs(a[3]-a[1])&&Math.abs(a[4]-a[0])==Math.abs(a[5]-a[1])&&Math.abs(a[6]-a[0])==Math.abs(a[7]-a[1])&&Math.abs(a[8]-a[0])==Math.abs(a[9]-a[1])&&Math.abs(a[10]-a[0])==Math.abs(a[11]-a[1])&&Math.abs(a[12]-a[10])==Math.abs(a[13]-a[1])&&Math.abs(a[14]-a[0])==Math.abs(a[15]-a[1]);
- //check
- if(c&d&e){
- f++;
- }
- System.arraycopy(a, 0, b, 2, 14);
- System.arraycopy(a, 14, b, 0, 2);
- System.arraycopy(b, 0, a, 0, 16);
- }
- if(f>0){
- System.out.println("YES");
- }else{
- System.out.println("NO");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement