Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- internal class Program
- {
- static void Main(string[] args)
- {
- int[] numbers = new int[10];
- int minRandom = 5;
- int maxRandom = 10;
- int repeatNumber = 0;
- int tempRepeat = 1;
- int repeat = 0;
- Random random = new Random();
- for (int i = 0; i < numbers.Length; i++)
- {
- numbers[i] = random.Next(minRandom, maxRandom);
- Console.Write(numbers[i] + " ");
- }
- for (int i = 0; i < numbers.Length - 1; i++)
- {
- if (numbers[i] == numbers[i + 1])
- {
- tempRepeat++;
- if (tempRepeat > repeat)
- {
- repeat = tempRepeat;
- repeatNumber = numbers[i];
- }
- }
- else
- {
- tempRepeat = 1;
- }
- }
- if (repeat == repeatNumber)
- {
- Console.WriteLine("- в этом массиве нет повоторяющихся чисел!");
- }
- else
- {
- Console.WriteLine($"число {repeatNumber} повторяется {repeat} раза подряд.");
- }
- Console.ReadKey();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement