Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- HashMap<String, Integer> wordToCount = new HashMap<>();
- for (String root : words) {
- if (!wordToCount.containsKey(root)) {
- wordToCount.put(root, 0);
- }
- wordToCount.put(root, wordToCount.get(root) + 1);
- }
- String[] words = new String[] { "Рыба", "Рыбаки", "1Рыба", "Два Гладиолуса", "Гладиолус" };
- for (int i = 0; i < words.length; i++)
- {
- for (int j = i + 1; j < words.length; j++)
- {
- if (words[i].length() < words[j].length())
- {
- if (words[j].contains(words[i]))
- {
- System.out.println(words[j] + " содержит " + words[i]);
- }
- }
- else
- {
- if (words[i].contains(words[j]))
- {
- System.out.println(words[i] + " содержит " + words[j]);
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment