Advertisement
silvana1303

palindrome integers

May 28th, 2020
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.93 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. using System.Numerics;
  5. using System.Text;
  6.  
  7. namespace exampreparation
  8. {
  9.     class exam
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Palindrome();
  14.         }
  15.  
  16.         static void Palindrome()
  17.         {
  18.             string command = Console.ReadLine();
  19.  
  20.             while (command != "END")
  21.             {
  22.                 char[] input = command.ToArray();
  23.                 char[] newInput = input.Reverse().ToArray();
  24.  
  25.                 string name = string.Join("", input);
  26.                 string name1 = string.Join("", newInput);
  27.  
  28.                 if (name == name1)
  29.                 {
  30.                     Console.WriteLine("true");
  31.                 }
  32.                 else
  33.                 {
  34.                     Console.WriteLine("false");
  35.                 }
  36.  
  37.                 command = Console.ReadLine();
  38.             }
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement