Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp2
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] input = Console.ReadLine().Split(' ', ',', '.', '?', '!');
- var palindromes = new List<string>();
- int lenght = input.Length;
- for (int i = 0; i < lenght; i++) // за думите от инпута
- {
- char[] word = input[i].ToCharArray(); // за буквите от всяка дума
- for (int j = 0; j < lenght; j++)
- {
- if (word[j] == word[lenght - 1 - j])
- {
- palindromes.Add(input[i]);
- }
- }
- }
- Console.WriteLine(string.Join(" ",palindromes.OrderBy(x => x)));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement