Created
May 30, 2025 02:42
-
-
Save ssshh3/c59e52dbe04f7f0ef2924c71513e7f3f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace ConsoleApp1 | |
{ | |
internal class Program | |
{ | |
static void Main(string[] args) | |
{ | |
int[] array = new int[30]; | |
int lastNumber = 10; | |
int repeatingNumber = 0; | |
int currentAmountOfRepetitions = 0; | |
int amountOfRepetitions = 0; | |
int currentNumber = array[0]; | |
Random random = new Random(); | |
for (int i = 0; i < array.Length; i++) | |
{ | |
array[i] = random.Next(0, lastNumber); | |
Console.Write($"{array[i]} "); | |
} | |
foreach (var number in array) | |
{ | |
if (number == currentNumber) | |
{ | |
currentAmountOfRepetitions++; | |
} | |
else | |
{ | |
currentAmountOfRepetitions = 1; | |
currentNumber = number; | |
} | |
if (currentAmountOfRepetitions > amountOfRepetitions) | |
{ | |
amountOfRepetitions = currentAmountOfRepetitions; | |
repeatingNumber = currentNumber; | |
} | |
} | |
Console.WriteLine($"\nЧисло {repeatingNumber} повторяется больше всех, количество повторений - {amountOfRepetitions}."); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment