Advertisement
skipter

C# Last 3 Equals word / List.Reverse()

Jun 24th, 2017
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.79 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. namespace _1.Last3EqualStrings
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             List<string> numberList = Console.ReadLine().Split(' ').ToList();
  13.  
  14.             numberList.Reverse();
  15.             for (int cnt = 0; cnt < numberList.Count; cnt++)
  16.             {
  17.                 string word = numberList[cnt];
  18.                 string word2 = numberList[cnt + 1];
  19.                 string word3 = numberList[cnt + 2];
  20.                 if (word == word2 && word2 == word3)
  21.                 {
  22.                     Console.WriteLine($"{word} {word2} {word3}");
  23.                     break;
  24.                 }
  25.             }            
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement