Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Main {
- /*
- * Example: 'abc def' --> 'fed cba'
- */
- public static void reverseAll(char[] text) {
- }
- /*
- * Example: 'abc def' --> 'cba fed'
- */
- public static void reverseWords(char[] text) {
- }
- /***************************/
- /***************************/
- /* DO NOT CHANGE DOWN HERE */
- /***************************/
- /***************************/
- public static void solve(String text) {
- System.out.println("Reversing string: " + text);
- char [] reversedAll = text.toCharArray();
- reverseAll(reversedAll);
- System.out.println(String.format("Result after reversing all: %s", new String(reversedAll)));
- char [] reversedWords = text.toCharArray();
- reverseWords(reversedWords);
- System.out.println(String.format("Result after reversing the words: %s", new String(reversedWords)));
- System.out.println();
- }
- public static void main(String[] args) {
- solve("abc def");
- solve("This is a sentence I want to reverse");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment