Given an English sentence, you are asked to write a program that reverses the order of all the words in the sentence.
input Format: The test input contains a test case that gives a string with a total length of not more than 500 000 in a row. A string consists of several words and a number of spaces, where the word is a string of letters (case-sensitive), separated by several spaces between the words.
output format: the output of each test case occupies one line, output the sentence after the reverse, and guarantee only 1 spaces between words.
Input Sample:
Hello World here I Come
Sample output:
Come I here World HelloImport Java.util.scanner;public class Main {public static void main (string[] args) {Scanner cin = new Scanner (system.in); S Tring str = cin.nextline (); string[] STRs = Str.split (""); Boolean isFirst = true;for (int i = strs.length-1; I >= 0; i--) {Strs[i] = Strs[i].trim (), if (IsFirst &&!strs[i].equals ("")) {System.out.print (strs[i]); isFirst = false;} else if (!strs[i].equals (")") {System.out.print ("" + Strs[i]);}}}
String-07. Irony-Enhanced Edition (20)