Advertisement
Danny_Berova

08.Nilapdromes

Jul 30th, 2017
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.32 KB | None | 0 0
  1.  
  2. namespace _08.Nilapdromes
  3. {
  4.     using System;
  5.     using System.Collections.Generic;
  6.     using System.Linq;
  7.  
  8.     public class Program
  9.     {
  10.         public static void Main()
  11.         {
  12.             string word = Console.ReadLine().ToLower();
  13.  
  14.             while (word != "end")
  15.             {
  16.                 string frontBorder = string.Empty;
  17.                 string backBorder = string.Empty;
  18.                 string border = string.Empty;
  19.  
  20.                 for (int i = 0; i < word.Length/2; i++)
  21.                 {
  22.                     frontBorder = frontBorder + word[0 + i];
  23.                     backBorder = word[word.Length - 1 - i] + backBorder;
  24.                     if (frontBorder == backBorder)
  25.                     {
  26.                         border = frontBorder;
  27.                     }
  28.                 }
  29.  
  30.                 if (border.Length > 0)
  31.                 {
  32.                     string core = word
  33.                         .Substring(border.Length, word.Length - (border.Length * 2));
  34.                     //string core = word.Replace(border, string.Empty);
  35.  
  36.                     if (core.Length > 0)
  37.                     {
  38.                         Console.WriteLine(core + border + core);
  39.                     }
  40.                 }
  41.  
  42.              word = Console.ReadLine();
  43.             }
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement