anizko

09. Palindrome Integers

Jul 2nd, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.13 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace _09._Palindrome_Integers
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             string comand = Console.ReadLine();
  11.  
  12.             while (comand != "END")
  13.             {
  14.                 bool isPalindrome = false;
  15.                 bool palindrome= FinePalindrome(comand, isPalindrome);
  16.                 if (palindrome==true)
  17.                 {
  18.                     Console.WriteLine("true");
  19.                 }
  20.                 else
  21.                 {
  22.                     Console.WriteLine("false");
  23.                 }
  24.                 comand = Console.ReadLine();
  25.             }
  26.         }
  27.  
  28.         static bool FinePalindrome(string comand, bool isPalindrome)
  29.         {
  30.             string newSrting = string.Empty;
  31.  
  32.             for (int i = comand.Length-1; i>=0 ; i--)
  33.             {
  34.                 char symbol = comand[i];
  35.                 newSrting += symbol;
  36.  
  37.                 if(newSrting == comand)
  38.                 {
  39.                     isPalindrome = true;
  40.                 }
  41.             }
  42.             return isPalindrome;
  43.         }
  44.     }
  45. }
Add Comment
Please, Sign In to add comment