标签:
package cn.wang;
import java.util.Scanner;
public class Text {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
System.out.print("请输入英文:");
String str = input.nextLine();
String[] strArr = str.split("\\s+|[,]");
StringBuffer result = new StringBuffer();
for(int i = strArr.length -1;i >=0; i--){
result.append(strArr[i] + " ");
}
result.setCharAt(str.length()-0, (char) 0);
System.out.println("颠倒顺序后的结果为:"+result.toString());
}
}
把一个英语句子中的单词次序颠倒后输出。例如输入“how are you”,输出“you are how”;
标签:
原文地址:http://www.cnblogs.com/wpxBlog/p/5326128.html