Advertisement
MZlatev

Untitled

Oct 18th, 2019
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _9._PalindromeIntegers
  4. {
  5. class PalindromeIntegers
  6. {
  7. static void Main()
  8. {
  9. string input = null;
  10. while ((input = Console.ReadLine()) != "END")
  11.  
  12. {
  13. bool isPalindrome = IsPalindrome(input);
  14. Console.WriteLine(isPalindrome.ToString().ToLower());
  15. }
  16. }
  17.  
  18. static bool IsPalindrome(string num)
  19. {
  20. bool isPalindrome = false;
  21.  
  22. for (int i = 0; i < num.Length / 2; i++)
  23. {
  24. int backwardIndex = num.Length - 1 - i;
  25.  
  26. if (num[i] == num[backwardIndex])
  27. {
  28. isPalindrome = true;
  29. break;
  30. }
  31. }
  32.  
  33. return isPalindrome;
  34. }
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement