Advertisement
Guest User

Untitled

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