Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void Main(string[] args)
- {
- Random random = new Random();
- int minNumber = 1;
- int maxNumber = 10;
- int countElement = 30;
- int countReapeat = 1;
- int maxOfCountRepeat = 0;
- int numberMaxOfCountRapeat;
- int[] array = new int[countElement];
- array[0] = random.Next(minNumber, maxNumber);
- numberMaxOfCountRapeat = array[0];
- Console.Write("Массив: ");
- for (int i = 1; i < array.Length; i++)
- {
- array[i] = random.Next(minNumber, maxNumber);
- Console.Write(array[i] + " ");
- if (array[i - 1] != array[i])
- {
- if (maxOfCountRepeat < countReapeat)
- {
- maxOfCountRepeat = countReapeat;
- numberMaxOfCountRapeat = array[i - 1];
- }
- countReapeat = 1;
- }
- else
- {
- countReapeat++;
- }
- }
- Console.WriteLine($"\nКол-во повторений: {maxOfCountRepeat}\n" +
- $"Число: {numberMaxOfCountRapeat}");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement