Advertisement
gospod1978

Methods-Ex\Palindrome Integers

Oct 13th, 2019
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.10 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Numerics;
  5.  
  6. namespace methods_exerci
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             string text;
  13.             while ((text = Console.ReadLine()) != "END")
  14.                 {
  15.                 Palindrome(text);
  16.                 }
  17.         }
  18.  
  19.         static void Palindrome(string text)
  20.         {
  21.  
  22.             List<string> number = new List<string>();
  23.  
  24.             for (int i = 0; i < text.Length; i++)
  25.             {
  26.                 number.Add(text[i].ToString());
  27.                
  28.             }
  29.  
  30.             string palindrome = "true";
  31.  
  32.            
  33.                 for (int i = 0; i < number.Count - 1; i++)
  34.                 {
  35.                     string one = number[i];
  36.                     string two = number[number.Count - 1 - i];
  37.                     if (one != two)
  38.                     {
  39.                         palindrome = "false";
  40.                     }
  41.                 }
  42.            
  43.             Console.WriteLine(palindrome);
  44.            
  45.         }
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement