UVA 11349 Java

  1. import java.util.*;
  2.  
  3. public class main{
  4. public static void main(String[] args) {
  5. Scanner sc=new Scanner(System.in);
  6. int cases = sc.nextInt();
  7. sc.nextLine();
  8. for(int times = 0; times < cases; times++)
  9. {
  10. String[] str = sc.nextLine().split(" ");
  11. int lines = Integer.parseInt(str[str.length - 1]);
  12. int[] input = new int[lines * lines];
  13. for(int i = 0; i < lines; i++)
  14. {
  15. String line = sc.nextLine().trim();
  16. String[] temp =line.split(" ");
  17. for(int j = 0; j < temp.length; j++)
  18. input[i * lines + j] = Integer.parseInt(temp[j]);
  19. }
  20. boolean check = true;
  21. for(int i = 0; i < input.length / 2; i++)
  22. if(input[i] != input[input.length-1-i] || input[i] < 0)
  23. {
  24. check = false;
  25. break;
  26. }
  27. System.out.printf("Test #%d: %s\r\n", times + 1, check ? "Symmetric." : "Non-symmetric.");
  28. }
  29. }
  30. };
  31.  

留言

這個網誌中的熱門文章

C# 井字遊戲