Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Random;
- import java.util.Scanner;
- public class Main{
- public static void main(String[] args){
- Random rnd = new Random(System.currentTimeMillis());
- Scanner in = new Scanner(System.in);
- int a=0 ,b =0;
- String s = new String();
- System.out.println("Введите предложение:");
- s = in.nextLine(); //вводим строку
- char[] c = s.toCharArray();
- for(int i = 0; i< c.length; i++){
- a=0;
- for(int j = i; j< c.length; j++){
- if (c[i] == c[j]) a++;
- }
- if (a>=b){
- b = a;
- }
- }
- System.out.print("Наиболее повторяющиеся символы: ");
- for(int i = 0; i< c.length; i++){
- a=0;
- for(int j = i; j< c.length; j++){
- if (c[i] == c[j]) a++;
- }
- if (a==b){
- System.out.print(c[i] + ";");
- }
- }
- System.out.println(" ");
- System.out.println("Колличество повторейний: " + b);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement