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;
- namespace Extended
- {
- class Program
- {
- public static bool IsPalindrome(string inp)
- {
- int min = 0;
- int max = inp.Length - 1;
- while (true)
- {
- if (min > max)
- {
- return true;
- }
- char a = inp[min];
- char b = inp[max];
- if (a != b)
- {
- return false;
- }
- min++;
- max--;
- }
- }
- static void Main(string[] args)
- {
- string[] input = Console.ReadLine().Split(new char[]{ ' ', ',', '!', '.', '?' }, StringSplitOptions.RemoveEmptyEntries);
- List<string> l = input.Where(x => IsPalindrome(x) == true).Select(x => x).ToList();
- l.Sort();
- l = l.Distinct().ToList();
- Console.WriteLine(string.Join(", ", l));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement