題目內容: dyt喜歡對lrh說的話說反話,現給出lrh說的k句話,輸出dyt所說的反話,
輸入格式
第一行是樣例個數k(k<10) 接下來k行,每行包含lrh說的一句話(每句話長度不超過50,且每句話由英文字母和空格組成(區分大小寫),單詞間用一個空格隔開,行末無多余空格),
輸出格式
針對每一句話,輸出dyt所說的反話,每句話占一行,
輸入樣例
2
hello world here i come
zxxz Tql
輸出樣例
come i here world hello
Tql zxxz
代碼:
import java.util.*; public class Main{ public static void main(String[] args) { Scanner scan=new Scanner(System.in); int n=scan.nextInt(); scan.nextLine();//注意吃掉enter while(n-->0){ String s=scan.nextLine(); String a[]=s.split(" "); System.out.print(a[a.length-1]); for(int i=a.length-2;i>=0;i--) System.out.print(" "+a[i]); System.out.println(); } } }
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/106067.html
標籤:其他
