Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Random random = new Random();
- int[] array = new int[30];
- int maxRandomNumber = 9;
- int minRandomNumber = 5;
- int repeatingNumber = 0;
- int countOfRepeating = 0;
- int repetition = 1;
- for (int i = 0; i < array.Length; i++)
- {
- array[i] = random.Next(minRandomNumber, maxRandomNumber + 1);
- Console.Write($"{array[i]} ");
- }
- for (int i = 0; i < array.Length - 1; i++)
- {
- if (array[i] == array[i + 1])
- {
- repetition++;
- }
- else
- {
- repetition = 1;
- }
- if (repetition > countOfRepeating)
- {
- countOfRepeating = repetition;
- repeatingNumber = array[i];
- }
- }
- Console.WriteLine($"\nЧисло {repeatingNumber} больше раз повторяется подряд\nКоличество повторений: {countOfRepeating}");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement