Reverse string output

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.