Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import java.io.*;
- import java.math.*;
- class Solution {
- public static void main(String args[]) {
- Scanner in = new Scanner(System.in);
- String S = in.nextLine();
- int fin = S.length()-1;
- for(int i = S.length()-1; i >= 0; i--)
- {
- if(S.charAt(i) == ' ')
- {
- for(int j = i+1; j <= fin; j++)
- System.out.print(S.charAt(j));
- System.out.print(" ");
- fin = i-1;
- }
- if(i == 0)
- {
- for(int j = i; j <= fin; j++)
- System.out.print(S.charAt(j));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement