Created
December 24, 2016 12:35
-
-
Save Soulstorm50/35fb4c93b378f1d46aea888a061d9f2a to your computer and use it in GitHub Desktop.
Палиндром C#
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Text.RegularExpressions; | |
public class Palindrom | |
{ | |
public static string Reverser(string a) | |
{ | |
char[] arr = a.ToCharArray(); | |
Array.Reverse(arr); | |
return new string(arr); | |
} | |
public static string Palindromer(string x) | |
{ | |
string y = Reverser(x); | |
Console.WriteLine(y); | |
if (Equals(x, y)) | |
return "Палиндром"; | |
else | |
return "Не палиндром"; | |
} | |
public static void Main() | |
{ | |
Console.Title = "Проверка на палиндромность."; | |
Console.WriteLine("Введите тестируемую строку"); | |
string pattern = @"\.+?|\,+?|\ +?|\-+?|\:+?"; | |
string input = Console.ReadLine(); | |
string str = input.ToLower(); | |
str = (Regex.Replace(str, pattern, string.Empty)); | |
Console.WriteLine(input + " - " + Palindromer(str)); | |
Console.WriteLine(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment