Advertisement
vasilivanov93

Untitled

Apr 24th, 2017
337
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _01.LastConsecutiveEqualStrings
  4. {
  5. public class LastConsecutiveEqualStrings
  6. {
  7. public static void Main()
  8. {
  9. string[] words = Console.ReadLine().Split(' ');
  10.  
  11. int count = 1;
  12.  
  13. for (int i = words.Length - 1; i > 0; i--)
  14. {
  15. if (words[i] == words[i - 1])
  16. {
  17. count++;
  18.  
  19. if (count == 3)
  20. {
  21. Console.WriteLine($"{words[i]} {words[i]} {words[i]}");
  22. break;
  23. }
  24. }
  25. else
  26. {
  27. count = 1;
  28. }
  29. }
  30. }
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement