TheBulgarianWolf

Palindrome Integers

Oct 31st, 2020
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.97 KB | None | 0 0
  1. using System;
  2. using System.Threading;
  3.  
  4. namespace ConsoleApp1
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             Console.Write("Start typing your numbers//TYPE 'END' TO STOP THE PROGRAM//: ");
  11.             PalindromeIntegers();
  12.            
  13.  
  14.         }
  15.  
  16.         static void PalindromeIntegers()
  17.         {
  18.             string int1;
  19.             while((int1 = Console.ReadLine()) != "END")
  20.             {
  21.                 string alternativeString = "";
  22.                 int stringLength = int1.Length;
  23.                 for(int i = stringLength - 1; i >= 0; i--)
  24.                 {
  25.                     alternativeString += int1[i];
  26.                 }
  27.                 if (int1.Equals(alternativeString))
  28.                 {
  29.                     Console.WriteLine("true");
  30.                 }
  31.                 else
  32.                 {
  33.                     Console.WriteLine("false");
  34.                 }
  35.             }
  36.         }
  37.        
  38.     }
  39. }
  40.  
Add Comment
Please, Sign In to add comment