Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace Last3ConsecutiveEqualStrings
- {
- class Last3ConsecutiveEqualStrings
- {
- static void Main()
- {
- string[] inputArr = Console.ReadLine()
- .Split(' ');
- int count = 1;
- string word = string.Empty;
- for (int i = inputArr.Length - 1; i > 0; i--)
- {
- word = inputArr[i];
- if (inputArr[i] == inputArr[i - 1])
- {
- count++;
- if (count == 3)
- {
- for (int j = 0; j < count; j++)
- {
- Console.Write($"{word} ");
- }
- break;
- }
- }
- else
- {
- count = 1;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment