﻿/*
* Problem 20. Palindromes
*Write a program that extracts from a given text all palindromes, e.g. ABBA, lamal, exe.
*/

using System;
using System.Collections.Generic;

class P20_Palindromes
{
    static void Main()
    {
        string input = "In as name to here them denyned wise this. Asa rapid woody mym he me which. Men butub they fail shewehs just wish next put. L";

        string[] words = input.Split(' ');
        List<string> palyndromes = new List<string>();

        foreach (string word in words)
        {
            char[] reversedArr = word.ToCharArray();
            Array.Reverse(reversedArr);
            string reversedWord = new string(reversedArr);

            if (word.ToUpper() == reversedWord.ToUpper())
            {
                palyndromes.Add(word);
            }
        }

        Console.WriteLine(string.Join(", ", palyndromes));
    }
}