Advertisement
valitomi

Untitled

Apr 27th, 2021
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 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 = true;
  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. if (isSymmetric) {
  31. System.out.println("Yes");
  32. } else {
  33. System.out.println("No");
  34. }
  35. isSymmetric = true;
  36. }
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement