Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace C_Ijun
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- Random random = new Random();
- int lowRangeRandom = 5;
- int highRangeRandom = 10;
- int duplicatesNum = lowRangeRandom;
- int localCountDuplicates = 1;
- int maxCountDuplicates = 1;
- int[] numbers = new int[30];
- for (int i = 0; i < numbers.Length; i++)
- {
- numbers[i] = random.Next(lowRangeRandom, highRangeRandom);
- }
- Console.WriteLine("Исходная матрица.\n");
- for (int i = 0; i < numbers.Length; i++)
- {
- Console.Write(numbers[i] + " ");
- }
- for (int i = 0; i < numbers.Length - 1; i++)
- {
- if (numbers[i] != numbers[i+1])
- {
- localCountDuplicates = 1;
- }
- else
- {
- localCountDuplicates++;
- if (localCountDuplicates > maxCountDuplicates)
- {
- duplicatesNum = numbers[i];
- maxCountDuplicates++;
- }
- }
- }
- Console.WriteLine($"\nСамая длинная строка повторов:\n{duplicatesNum}\n" +
- $"Число повторов:\n{maxCountDuplicates}");
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement