Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void Main()
- {
- Console.WriteLine(Pali("Was it a car or a cat I saw"));
- }
- public static bool Pali(string input)
- {
- string word = input.ToLower();
- string result ="";
- string reverse = "";
- for (int i = 0; i < input.Length; i++)
- {
- if(input[i] != ' ')
- reverse += word[i];
- }
- for(int i = input.Length -1; i >= 0; i--)
- {
- if(input[i] != ' ')
- result += word[i];
- }
- if(reverse == result)
- return true;
- else
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement