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 _04
- {
- class Program
- {
- static void Main(string[] args)
- {
- char[] split = { ' ', ',', '.', '?', '!' };
- string[] array = Console.ReadLine().Split(split);
- foreach (string value in array)
- {
- if (IsPalindrome(value))
- {
- Console.Write(string.Join(", ", value));
- }
- }
- Console.WriteLine();
- }
- static bool IsPalindrome(string value)
- {
- int min = 0;
- int max = value.Length - 1;
- while (true)
- {
- if (min > max)
- {
- return true;
- }
- char a = value[min];
- char b = value[max];
- if (a != b)
- {
- return false;
- }
- min++;
- max--;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement