Guest User

Untitled

a guest
Feb 23rd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. namespace Palindrome
  2. {
  3. class Class1
  4. {
  5. static void Main(string[] args)
  6. {
  7. while (true)
  8. {
  9. Console.WriteLine("Digit a word:");
  10. string word = Console.ReadLine();
  11.  
  12. if (word == "exit")
  13. break;
  14.  
  15. VerifyPalindrome(word);
  16. }
  17. }
  18.  
  19. private static void VerifyPalindrome(string word)
  20. {
  21. bool compare = true;
  22. int i = 0;
  23. while (i < (word.Length / 2) - 1)
  24. {
  25. if (compare)
  26. {
  27. for (int j = word.Length - 1; j >= 0; j--)
  28. {
  29. if (word[i] == word[j])
  30. compare = true;
  31. else
  32. {
  33. compare = false;
  34. break;
  35. }
  36. i++;
  37. }
  38. }
  39. else
  40. break;
  41. }
  42.  
  43. if (compare)
  44. Console.WriteLine("This is a Palindrome word");
  45. else
  46. Console.WriteLine("This is NOT a Palindrome word");
  47. }
  48. }
  49. }
Add Comment
Please, Sign In to add comment