1062 Text Reverse

import java.util.Scanner;
 
public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		sc.nextLine();
 
		while (t-- > 0)
		{
			String str = sc.nextLine();
			String []strs = str.split(" ");
			String output = "";
			for (int i = 0; i < strs.length; i++)
			{
				for (int j = strs[i].length() - 1; j >= 0; j--)
					output += strs[i].charAt(j);
				if ((i + 1) == strs.length)
					continue;
				output += " ";
			}
 
			if (str.endsWith(" "))
				output += " ";
 
			System.out.println(output);
		}
	}
}
原文地址:https://www.cnblogs.com/cznczai/p/11150295.html