UVA 11349 Java

import java.util.*;

public class main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int cases = sc.nextInt();
    sc.nextLine();
    for(int times = 0; times < cases; times++)
    {
    	String[] str = sc.nextLine().split(" ");
		int lines = Integer.parseInt(str[str.length - 1]);
		int[] input = new int[lines * lines];
		for(int i = 0; i < lines; i++)
		{
			String line = sc.nextLine().trim();
			String[] temp =line.split(" ");
			for(int j = 0; j < temp.length; j++)
				input[i * lines + j] = Integer.parseInt(temp[j]);
		}
		boolean check = true;
		for(int i = 0; i < input.length / 2; i++)
			if(input[i] != input[input.length-1-i] || input[i] < 0)
			{
				check = false;
				break;
			}
		System.out.printf("Test #%d: %s\r\n", times + 1, check ? "Symmetric." : "Non-symmetric.");
    }
  }
};

留言

這個網誌中的熱門文章

C# 井字遊戲