标签:style blog ar color os sp java for on
描述给定一行字符,逆序输出此行(空格.数字不输出)
3
abc 123de
abc 123
abc d
edcba
cba
1 import java.util.Arrays; 2 import java.util.Scanner; 3 4 public class Main { 5 public static void main(String[] args) { 6 Scanner scanner=new Scanner(System.in); 7 int T; 8 String s; 9 char sChar[]=new char[41]; 10 int i; 11 12 T=scanner.nextInt(); 13 s=scanner.nextLine(); 14 while(true){ 15 if(T==0) 16 break; 17 T--; 18 19 s=scanner.nextLine(); 20 s=new StringBuffer(s).reverse().toString(); 21 sChar=s.toCharArray(); 22 23 for(i=0;i<sChar.length;i++){ 24 if(Character.isLetter(sChar[i])) 25 System.out.print(sChar[i]); 26 } 27 System.out.println(); 28 } 29 } 30 }
标签:style blog ar color os sp java for on
原文地址:http://www.cnblogs.com/zqxLonely/p/4133064.html