Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text;
- class LongestAreaInArray
- {
- static void Main()
- {
- int n = int.Parse(Console.ReadLine());
- string[] strings = new string[n];
- int count = 1;
- int maxCount = 1;
- string theWord;
- for (int i = 0; i < n; i++)
- {
- strings[i] = Console.ReadLine().Trim();
- }
- theWord = strings[0];
- for (int i = 0; i < strings.Length - 1; i++)
- {
- if (strings[i] == strings[i + 1])
- {
- count++;
- if (count > maxCount)
- {
- maxCount = count;
- theWord = strings[i];
- }
- }
- else
- {
- count = 1;
- }
- }
- var sb = new StringBuilder();
- sb.AppendLine(maxCount.ToString());
- for (int i = 0; i < maxCount; i++)
- {
- sb.AppendLine(theWord);
- }
- Console.WriteLine();
- Console.Write(sb);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement