Describes the given line of characters, outputting the line in reverse order (space. Number not output)
-
- Input
-
The
- first line is an integer N (n<10) that represents the number of groups of test data)
Each set of test data has one row, and there is only a single space in the middle of each row of data (so you can read this line as a two string).
Each line character length does not exceed 40
and ensure that the characters entered are only spaces (1), numbers, lowercase letters three
-
- Output
-
- corresponding to each line of test data, reverse output (spaces and numbers do not output)
-
- Sample input
-
-
3ABC 123DEABC 123ABC D
-
- Sample output
-
Edcbacba
1 Importjava.util.Arrays;2 ImportJava.util.Scanner;3 4 Public classMain {5 Public Static voidMain (string[] args) {6Scanner scanner=NewScanner (system.in);7 intT;8 String S;9 Charschar[]=New Char[41];Ten inti; One At=scanner.nextint (); -s=scanner.nextline (); - while(true){ the if(t==0) - Break; -t--; - +s=scanner.nextline (); -s=NewStringBuffer (s). Reverse (). toString (); +Schar=S.tochararray (); A at for(i=0;i<schar.length;i++){ - if(Character.isletter (Schar[i])) - System.out.print (Schar[i]); - } - System.out.println (); - } in } -}
Reverse string output