Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static class Program
- {
- //with string and char list method :)
- static void Main()
- {
- Console.WriteLine("Give me a number");
- List<char>? numb = Console.ReadLine()?.ToCharArray().ToList();
- string palidrome = string.Empty;
- string origin = string.Empty;
- if (numb != null)
- {
- foreach (char item in numb)
- {
- origin += item;
- }
- numb.Reverse();
- foreach (char item in numb)
- {
- palidrome += item;
- }
- Console.WriteLine(origin.Equals(palidrome) ? "Palindrome" : "Not Palindrome");
- }
- }
- }
- //Python version 2x
- n=0
- original =0
- reverzed = 0
- reminder =0
- n = int(input('Give me a number!\n'))
- original = n
- while (n!=0):
- reminder = n % 10
- reverzed = reverzed * 10 + reminder
- n //=10
- if (original == reverzed):
- print("Palindrom")
- else:
- print("Not palindrom")
- """
- #No way in c#
- s = input('Give me a number!\n')
- if s == s[::-1]:
- print("Palindrom")
- else:
- print("Not palindrom")
- """
Advertisement
Add Comment
Please, Sign In to add comment