mirror of
https://github.com/theoludwig/programming-challenges.git
synced 2024-12-08 00:45:29 +01:00
feat(solutions): add is-palindrome/cs/function
This commit is contained in:
parent
2e15a21206
commit
02bfe7454f
3
challenges/is-palindrome/solutions/cs/function/README.md
Normal file
3
challenges/is-palindrome/solutions/cs/function/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
# is-palindrome/cs/function
|
||||
|
||||
Created by [@Divlo](https://github.com/Divlo) on 10 September 2021.
|
26
challenges/is-palindrome/solutions/cs/function/Solution.cs
Normal file
26
challenges/is-palindrome/solutions/cs/function/Solution.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using System;
|
||||
|
||||
namespace Solution
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main()
|
||||
{
|
||||
string line = Console.ReadLine();
|
||||
line = line.ToLower().Replace(" ", "");
|
||||
string reverse = "";
|
||||
for (int index = line.Length - 1; index >= 0; index--)
|
||||
{
|
||||
reverse += line[index];
|
||||
}
|
||||
if (line == reverse)
|
||||
{
|
||||
Console.WriteLine("true");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("false");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user