Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int[] array = new int[] { 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8 };
- int counter = 1;
- int rememberNumner = 0;
- int repetitionСouneter = 0;
- foreach (var numbers in array)
- {
- Console.Write($"{numbers} ");
- }
- for (int i = 0; i < array.Length - 1 ; i++)
- {
- if(array[i] == (array[i + 1]))
- {
- counter++;
- }
- else if (counter > repetitionСouneter)
- {
- repetitionСouneter = counter;
- rememberNumner = array[i];
- counter = 1;
- }
- else
- {
- counter = 1;
- }
- }
- Console.WriteLine($"\nЧисло {rememberNumner} повторяется {repetitionСouneter}");
Advertisement
Add Comment
Please, Sign In to add comment