desislava777

03. Phoenix Grid

Oct 30th, 2017
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 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 ConsoleApplication24
  8. {
  9. class Program
  10. {
  11. public static bool IsPalindrome(string value)
  12. {
  13. int min = 0;
  14. int max = value.Length - 1;
  15. while (true)
  16. {
  17. if (min > max)
  18. {
  19. return true;
  20. }
  21. char a = value[min];
  22. char b = value[max];
  23. if (char.ToLower(a) != char.ToLower(b))
  24. {
  25. return false;
  26. }
  27. min++;
  28. max--;
  29. }
  30. }
  31. static void Main(string[] args)
  32. {
  33. string input = Console.ReadLine();
  34. while (input != "ReadMe")
  35. {
  36. bool palindrom = IsPalindrome(input);
  37. if (palindrom && !input.Contains(" ") && !input.Contains("_"))
  38. {
  39. Console.WriteLine("YES");
  40. }
  41. else
  42. {
  43. Console.WriteLine("NO");
  44. }
  45. input = Console.ReadLine();
  46. }
  47. }
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment