dyt ironic (Note string input)

Title Contents: dyt lrh like to say the words of irony, is given lrh say k words, said output dyt irony.

Input Format

The first line is a sample number k (k <10) the next k rows, each row comprising said lrh word (every word length of not more than 50, every word and English letters and spaces (case sensitive ), separated by a space between words, end of the line without extra spaces).

Output Format

For each word, said output dyt irony, every word per line.

SAMPLE INPUT

2
hello world here i come
zxxz Tql
 

Sample Output

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 (); // Note eaten 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();
            }
    }
}

 


Guess you like

Origin www.cnblogs.com/qdu-lkc/p/12207221.html