Aborigenius

RepeatThreeTimes

Jun 19th, 2017
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.87 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 Exrecises
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string[] repeat = Console.ReadLine().Split(' ');
  14.  
  15.             int count = 1;
  16.             for (int i = repeat.Length - 1; i >= 0; i--)
  17.             {
  18.                
  19.                 if (repeat[i] == repeat[i-1])
  20.                 {
  21.                     count++;
  22.                     if (count == 3)
  23.                     {
  24.                         Console.WriteLine($"{repeat[i]} {repeat[i]} {repeat[i]}");
  25.                         break;
  26.                     }
  27.                    
  28.                 }
  29.                 else
  30.                 {
  31.                     count = 1;
  32.                 }
  33.             }
  34.  
  35.            
  36.         }
  37.  
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment