Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace Last3ConsecutiveEqualStrings
- {
- class MainClass
- {
- public static void Main(string[] args)
- {
- List<string> text = Console.ReadLine().Split().ToList();
- List<string> concat = new List<string>();
- for (int i=text.Count-1; i>=2 ; i--)
- {
- if (text[i] == text[i - 1] && text[i-1] == text[i -2])
- {
- concat.Add(text[i]);
- concat.Add(text[i - 1]);
- concat.Add(text[i - 2]);
- break;
- }
- else
- {
- continue;
- }
- }
- Console.WriteLine(string.Join(" ",concat));
- }
- }
- }
Add Comment
Please, Sign In to add comment