Advertisement
YavorGrancharov

Last_3_Consecutive_Equal_Strings

Jun 18th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.88 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Last_3_Consecutive_Equal_Strings
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string[] array = Console.ReadLine()
  14.                 .Split(' ')
  15.                 .ToArray();
  16.  
  17.             int count = 1;
  18.  
  19.             for (int i = array.Length - 1; i > 0; i--)
  20.             {
  21.                 if (array[i] == array[i - 1])
  22.                 {
  23.                     count++;
  24.  
  25.                     if (count == 3)
  26.                     {
  27.                         Console.WriteLine($"{array[i]} {array[i]} {array[i]}");
  28.                         break;
  29.                     }
  30.                 }
  31.                 else
  32.                 {
  33.                     count = 1;
  34.                 }
  35.             }
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement