Home
C# Palindrome Number Problem
using System;
using System.Linq;
class Program
{
static void Main()
{
int x = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(IsPalindrome(x));
}
public static bool IsPalindrome(int x)
{
string y = Convert.ToString(x);
List<char> myList = y.ToList();
bool isTrue = true;
for (int i = 0; i < myList.Count / 2; i++)
{
Console.WriteLine(i + " " + (myList.Count - 1 - i));
if (myList[i] != myList[myList.Count - 1 - i])
{
isTrue = false;
}
}
return isTrue;
}
}
Reader's Comments
Name
Comment
Add a RELEVANT link (not required)
Upload an image (not required)
Uploading...
Home