Created
November 12, 2017 21:29
-
-
Save 13andrew13/25243f0b80a9edfd41fcdbe36bfe2a12 to your computer and use it in GitHub Desktop.
Anagrams
На вход консольного приложения передается строка слов, разделенных пробелами. Твоя задача сделать из слов анаграммы ("задом наперед") при этом оставив порядок слов неизменными. Результат вывести в консоль. Пример "мама мыла раму" => "амам алым умар"
При решении задачи нельзя использовать дополнительную память. В том числе, когда это про…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Main { | |
public static void main(String[] args) { | |
for (String s : args[0].split(" ")) { | |
System.out.print(" "); | |
print(s.length(),s); | |
} | |
} | |
public static void print(int i,String s){ | |
if(i==0){ | |
return; | |
} | |
System.out.print(s.toCharArray()[i-1] ); | |
print(i-1,s); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment