Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Bukva {
  4.  
  5. public static void main(String[] args) {
  6. Scanner sc = new Scanner(System.in);
  7. String s1 = sc.nextLine();
  8. String s2 = sc.nextLine();
  9. int best = 0, c = 0;
  10. char bestch = 0;
  11.  
  12. for (int i = 0; i < s1.length(); i++) {
  13. c = 0;
  14. for(int j = 0; j < s2.length(); j++) {
  15. if(s1.charAt(i) == s2.charAt(j)) {
  16. c++;
  17. }
  18. }
  19. if(c > best) {
  20. best = c;
  21. bestch = s1.charAt(i);
  22. }
  23. }
  24.  
  25. System.out.println("Bukva: " + bestch);
  26. System.out.println("Povtarqne: " + best);
  27. sc.close();
  28. }
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement