Initial commit
This commit is contained in:
20
10.8-Palindrome/Palindrome.cs
Normal file
20
10.8-Palindrome/Palindrome.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
|
||||
class Palindrome {
|
||||
public static void Main() {
|
||||
string test = "Sallad i Dallas";
|
||||
|
||||
test = test.ToLower();
|
||||
Console.WriteLine("Ar texten \"{0}\" ett Palindrom?: {1}", test, isPalindrome(test));
|
||||
}
|
||||
|
||||
static bool isPalindrome(string input) {
|
||||
int length = input.Length;
|
||||
|
||||
for (int i = 0; i < length / 2; i++) {
|
||||
if (input[i] != input[length - i - 1])
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user