Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import java.io.*;
- import java.math.*;
- /**
- * Objectif
- *
- * Inverser l'ordre des mots dans une phrase donnée.
- *
- * Entrée
- * Ligne 1 : Une phrase s.
- *
- * Sortie
- * Une phrase avec les mots dans l'ordre inverse.
- *
- * Contraintes
- * Aucune.
- *
- * Exemple
- * Test 1
- * Entrée
- * Hello there!!
- *
- * Sortie attendue
- * there!! Hello
- *
- * Test 2
- * Entrée
- * We had a three-course meal.
- *
- * Sortie attendue
- * meal. three-course a had We
- *
- * Test 3
- * Entrée
- * Oh, how I'd love to go!
- *
- * Sortie attendue
- * go! to love I'd how Oh,
- *
- * Test 4
- * Entrée
- * Reaching the large house near the Horse Guards' barracks, in which Anatole lived, Pierre entered the lighted porch, ascended the stairs, and went in at the open door.
- *
- * Sortie attendue
- * door. open the at in went and stairs, the ascended porch, lighted the entered Pierre lived, Anatole which in, barracks, Guards' Horse the near house large the Reaching
- */
- class Solution {
- public static void main(String args[]) {
- Scanner in = new Scanner(System.in);
- String s = in.nextLine();
- String[] t = s.split(" ");
- System.out.print(t[t.length-1]);
- for (int i=t.length-2; i >= 0; i--) {
- System.out.print(" " + t[i]);
- }
- System.out.println();
- }
- }
Advertisement
Comments
-
- .hjv
- -,m jnupghvtdcvgfredtgf5fvtd4rdcrswxea<6768r3e5tf456h876431233e54f5445tftre
Add Comment
Please, Sign In to add comment
Advertisement