Advertisement
Guest User

Untitled

a guest
Oct 19th, 2016
369
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 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 _04
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. char[] split = { ' ', ',', '.', '?', '!' };
  14. string[] array = Console.ReadLine().Split(split);
  15.  
  16. foreach (string value in array)
  17. {
  18. if (IsPalindrome(value))
  19. {
  20. Console.Write(string.Join(", ", value));
  21. }
  22. }
  23. Console.WriteLine();
  24. }
  25. static bool IsPalindrome(string value)
  26. {
  27. int min = 0;
  28. int max = value.Length - 1;
  29. while (true)
  30. {
  31. if (min > max)
  32. {
  33. return true;
  34. }
  35. char a = value[min];
  36. char b = value[max];
  37. if (a != b)
  38. {
  39. return false;
  40. }
  41. min++;
  42. max--;
  43. }
  44. }
  45.  
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement