//input - MADAM
//output -MADAM
static void Main(string[] args)
{
string a= Console.ReadLine();
int len = a.Length;
int loopC=a.Length/2;
bool iseven=((a.Length%2)==0) ? true:false;
if(!iseven)
loopC = (a.Length / 2) + 1;
for (int i = 0; i < loopC; i++)
{
if (a[i] == a[len - 1])
len--;
else
{
Console.WriteLine("not palindrome");
break;
}
}
Console.WriteLine(" palindrome");
Console.ReadLine();
}
//output -MADAM
static void Main(string[] args)
{
string a= Console.ReadLine();
int len = a.Length;
int loopC=a.Length/2;
bool iseven=((a.Length%2)==0) ? true:false;
if(!iseven)
loopC = (a.Length / 2) + 1;
for (int i = 0; i < loopC; i++)
{
if (a[i] == a[len - 1])
len--;
else
{
Console.WriteLine("not palindrome");
break;
}
}
Console.WriteLine(" palindrome");
Console.ReadLine();
}
No comments:
Post a Comment