Advertisement
GabrielDas

Untitled

Feb 14th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.90 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace P09PalindromeIntegers
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string input =Console.ReadLine();
  14.  
  15.             do
  16.             {
  17.                
  18.                 string firstTemp = "";
  19.                 string secondTemp = "";
  20.  
  21.                 if (input.Length % 2 != 0)
  22.                 {
  23.                     for (int i = 0; i < input.Length / 2; i++)
  24.                     {
  25.                         firstTemp += input[i];
  26.  
  27.                     }
  28.  
  29.                     for (int k = input.Length - 1; k > input.Length / 2; k--)
  30.                     {
  31.                         secondTemp += input[k];
  32.                     }
  33.  
  34.                     if (firstTemp == secondTemp)
  35.                     {
  36.                         Console.WriteLine("true");
  37.                     }
  38.                     else
  39.                     {
  40.                         Console.WriteLine("false");
  41.                     }
  42.                     input = Console.ReadLine();
  43.                 }
  44.                 else
  45.                 {
  46.                     for (int i = 0; i < input.Length / 2; i++)
  47.                     {
  48.                         firstTemp += input[i];
  49.  
  50.                     }
  51.  
  52.                     for (int k = input.Length - 1; k >= input.Length / 2; k--)
  53.                     {
  54.                         secondTemp += input[k];
  55.                     }
  56.  
  57.                     if (firstTemp == secondTemp)
  58.                     {
  59.                         Console.WriteLine("true");
  60.                     }
  61.                     else
  62.                     {
  63.                         Console.WriteLine("false");
  64.                     }
  65.                     input = Console.ReadLine();
  66.  
  67.                 }
  68.  
  69.             } while (input != "END");
  70.  
  71.  
  72.         }
  73.     }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement