Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- class MaxSequenceOfEqualElements
- {
- static void Main()
- {
- List<double> list = Console.ReadLine().Split().Select(double.Parse).ToList();
- int counter = 1;
- int tempCounter = 1;
- double resultNum = 0;
- for (int i = 0; i < list.Count; i++)
- {
- if (i+1 >= list.Count)
- {
- break;
- }
- if ((list[i] == list[i + 1]) && ((i+1) < list.Count))
- {
- tempCounter++;
- if (tempCounter > counter)
- {
- resultNum = list[i];
- counter = tempCounter;
- tempCounter = 1;
- }
- }
- else
- {
- tempCounter = 1;
- }
- }
- for (int i = 0; i < counter; i++)
- {
- Console.Write(resultNum + " ");
- }
- }
- }
Add Comment
Please, Sign In to add comment