Advertisement
Ronka

Untitled

Jun 27th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 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 ConsoleApp2
  8. {
  9. class Program
  10. {
  11.  
  12. static void Main(string[] args)
  13. {
  14. string[] input = Console.ReadLine().Split(' ', ',', '.', '?', '!');
  15.  
  16. var palindromes = new List<string>();
  17. int lenght = input.Length;
  18.  
  19. for (int i = 0; i < lenght; i++) // за думите от инпута
  20. {
  21. char[] word = input[i].ToCharArray(); // за буквите от всяка дума
  22. for (int j = 0; j < lenght; j++)
  23. {
  24. if (word[j] == word[lenght - 1 - j])
  25. {
  26. palindromes.Add(input[i]);
  27. }
  28. }
  29. }
  30.  
  31. Console.WriteLine(string.Join(" ",palindromes.OrderBy(x => x)));
  32. }
  33. }
  34.  
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement