本文共 639 字,大约阅读时间需要 2 分钟。
import java.io.BufferedInputStream;import java.util.Scanner;public class Main { public static void main(String args[]) { Scanner in = new Scanner(new BufferedInputStream(System.in)); int n = in.nextInt(); String s = in.nextLine();//吃掉换行符不可丢掉 while(n-- > 0) { String string = in.nextLine(); String [] array = string.split(" "); String temp = ""; for(int i = 0; i < array.length; i++ ) { for(int j = array[i].length()-1; j >= 0; j-- ) { temp += array[i].charAt(j); } if(i + 1 == array.length) continue; temp += " "; } if(string.endsWith(" "))//防止原字符串尾部有空格 temp += " "; System.out.println(temp); } }}
转载地址:http://hoimi.baihongyu.com/