zoukankan      html  css  js  c++  java
  • dyt说反话(注意字符串输入)

    题目内容: dyt喜欢对lrh说的话说反话,现给出lrh说的k句话,输出dyt所说的反话。

    输入格式

    第一行是样例个数k(k<10) 接下来k行,每行包含lrh说的一句话(每句话长度不超过50,且每句话由英文字母和空格组成(区分大小写),单词间用一个空格隔开,行末无多余空格)。

    输出格式

    针对每一句话,输出dyt所说的反话,每句话占一行。

    输入样例

    2
    hello world here i come
    zxxz Tql
    
     

    输出样例

    come i here world hello
    Tql zxxz

    代码:
    import java.util.*;
    
    public class Main{
          public static void main(String[] args) {
                Scanner scan=new Scanner(System.in);
                int n=scan.nextInt();
                scan.nextLine();//注意吃掉enter
                while(n-->0){
                      String s=scan.nextLine();
                      String a[]=s.split(" ");
                      System.out.print(a[a.length-1]);
                      for(int i=a.length-2;i>=0;i--) System.out.print(" "+a[i]);
                      System.out.println();
                }
        }
    }

  • 相关阅读:
    Binary Tree Inorder Traversal
    Populating Next Right Pointers in Each Node
    Minimum Depth of Binary Tree
    Majority Element
    Excel Sheet Column Number
    Reverse Bits
    Happy Number
    House Robber
    Remove Linked List Elements
    Contains Duplicate
  • 原文地址:https://www.cnblogs.com/qdu-lkc/p/12207221.html
Copyright © 2011-2022 走看看