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);
        }
    }
}
全部评论

相关推荐

哈哈哈,你是老六:看着项目比较少
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务