Guest User

Untitled

a guest
Jan 18th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. HashMap<String, Integer> wordToCount = new HashMap<>();
  2. for (String root : words) {
  3. if (!wordToCount.containsKey(root)) {
  4. wordToCount.put(root, 0);
  5. }
  6. wordToCount.put(root, wordToCount.get(root) + 1);
  7. }
  8.  
  9. String[] words = new String[] { "Рыба", "Рыбаки", "1Рыба", "Два Гладиолуса", "Гладиолус" };
  10. for (int i = 0; i < words.length; i++)
  11. {
  12. for (int j = i + 1; j < words.length; j++)
  13. {
  14. if (words[i].length() < words[j].length())
  15. {
  16. if (words[j].contains(words[i]))
  17. {
  18. System.out.println(words[j] + " содержит " + words[i]);
  19. }
  20. }
  21. else
  22. {
  23. if (words[i].contains(words[j]))
  24. {
  25. System.out.println(words[i] + " содержит " + words[j]);
  26. }
  27. }
  28. }
  29. }
Add Comment
Please, Sign In to add comment