第一行有一个整数。
随后组数据。
每组的第一行有一个整数。
每组的第二行有一个字符串,仅包含小写英文字符和空格,保证字符串首尾都不是空格。
保证。
输出行,每行一个字符串,代表倒置后的字符串
。
3 9 one space 11 two spaces 14 three spaces
ecapseno secapsowt secapseerht
import java.util.Scanner; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int t = 0; if(in.hasNextInt()){ t = in.nextInt(); } int n = 0; while(0<t--){ if(in.hasNextInt()){ n = in.nextInt(); } // 消除空行 in.nextLine(); StringBuilder sb = new StringBuilder(); if (in.hasNextLine()){ sb.append(in.nextLine().replaceAll(" ","")); } System.out.println(sb.reverse()); } in.close(); } }