ZOJ-1151

import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);

		int count = sc.nextInt();

		for (int i = 0; i < count; i++)
		{
			sc.nextLine();
			int c = sc.nextInt();
			sc.nextLine();
			for (int j = 0; j < c; j++)
			{
				String s = sc.nextLine();
				System.out.println(process(s));
			}

			if (i < count - 1)
				System.out.println();
		}
	}

	static String process(String s)
	{
		String[] ss = s.split(" ");
		StringBuilder sb = new StringBuilder();
		for (String str : ss)
		{
			for (int i = str.length() - 1; i >= 0; i--)
			{
				sb.append(str.charAt(i));
			}
			sb.append(" ");
		}
		return sb.toString().trim();
	}
}

你可能感兴趣的:(ZOJ)