Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Homework3_5
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- Random random = new Random();
- int[] numbers = new int[30];
- int identicalNumber = 0;
- int repetitionCounter = 1;
- int numberRepetitions = 0;
- int minNumber = 1;
- int maxNumber = 30;
- for (int i = 0; i < numbers.Length; i++)
- {
- numbers[i] = random.Next(minNumber, maxNumber + 1);
- Console.Write(numbers[i] + " ");
- }
- for (int i = 1; i < numbers.Length; i++)
- {
- if (numbers[i] == numbers[i - 1])
- {
- repetitionCounter++;
- }
- else
- {
- repetitionCounter = 1;
- }
- if (numberRepetitions < repetitionCounter)
- {
- numberRepetitions = repetitionCounter;
- identicalNumber = numbers[i];
- }
- }
- Console.WriteLine("\nчисло " + identicalNumber + " повторяется " + numberRepetitions + " раза подряд.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement