zoukankan      html  css  js  c++  java
  • 把一个英语句子中的单词次序颠倒后输出。例如输入“how are you”,输出“you are how”

    import java.util.Scanner;
    
    public class two{
    
            public static void main(String[] args) {
    
                    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());
    
        }
    
            public void countWord(String string) {
                // TODO Auto-generated method stub
                
            } 
    
    }
    
     
    import static org.junit.Assert.*;
    import org.junit.Test;
    
    public class testTest {
    
    @Test
    public void testCountWord() {
    two demo = new two();
    }
    
    }

  • 相关阅读:
    PHP闭包的用法
    composer相关命令
    keepalievd
    docker-compose
    rabbitmq 知识点
    免费的mysql客户端管理工具
    git生成密钥
    rabbitmq在docker下进行cluster
    http状态码
    vmplayer固定IP
  • 原文地址:https://www.cnblogs.com/xyp0911/p/5324140.html
Copyright © 2011-2022 走看看