Advertisement
kaloyan99

Untitled

Apr 27th, 2021
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.16 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.  
  5.     public static void main(String[] args) {
  6.         Scanner scanner = new Scanner(System.in);
  7.         String firstLine = scanner.nextLine();
  8.         int numberOfLines = Integer.parseInt(firstLine);
  9.         int counter = 1;
  10.         boolean isSymmetric = false;
  11.  
  12.         for (int i = 0; i < numberOfLines; i++) {
  13.             String input = scanner.nextLine();
  14.             String[] line = input.split(" ");
  15.             Integer[] array = new Integer[line.length];
  16.  
  17.             for (int j = 0; j < line.length; j++) {
  18.                 array[j] = Integer.parseInt(line[j]);
  19.             }
  20.             counter = 1;
  21.             for (int j = 0; j < line.length / 2; j++) {
  22.                 if (array[j].equals(array[array.length - counter])) {
  23.                     counter++;
  24.                     isSymmetric = true;
  25.                 } else {
  26.                     isSymmetric = false;
  27.                     break;
  28.                 }
  29.             }
  30.             System.out.println();
  31.             if (isSymmetric) {
  32.                 System.out.println("Yes");
  33.             } else System.out.println("No");
  34.         }
  35.     }
  36. }
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement