Advertisement
Guest User

Untitled

a guest
Jun 7th, 2016
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. class C
  4. {
  5. static void Main()
  6. {
  7. string input = Console.ReadLine();
  8.  
  9. if (IsPalindrome(input))
  10. {
  11. Console.WriteLine(-1);
  12. }
  13. else
  14. {
  15. for (int i = 0; i < input.Length; i++)
  16. {
  17. string a = input.Remove(i, 1);
  18. var b = a.Reverse();
  19. if (a == (string)b)
  20. {
  21. Console.WriteLine(i);
  22. }
  23. }
  24. }
  25. }
  26. static bool IsPalindrome(string word)
  27. {
  28. for (int i = 0; i < word.Length / 2; i++)
  29. {
  30. if (word[i] != word[word.Length - 1 - i]) return false;
  31. }
  32. return true;
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement