Fork me on GitHub

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);
		}
	}
}
posted @ 2019-07-08 11:56  cznczai  阅读(96)  评论(0编辑  收藏  举报