Advertisement
alexbancheva

Deciphering_06.04.2019

Oct 23rd, 2020
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.38 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Text.RegularExpressions;
  4. using System.Collections.Generic;
  5. using System.Text;
  6.  
  7. namespace Deciphering_FinalExam_06._04._2019
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             char[] input = Console.ReadLine().ToCharArray();
  14.             string[] secLine = Console.ReadLine().Split(" ").ToArray();
  15.             string previous = secLine[0];
  16.             string next = secLine[1];
  17.             StringBuilder descrypt = new StringBuilder();
  18.  
  19.             for (int i = 0; i < input.Length; i++)
  20.             {
  21.                 char symb = input[i];
  22.                
  23.                 if ((symb >= 'd' && symb <= 'z') || symb == '{' || symb == '}' || symb == '|' || symb == '#' )
  24.                 {
  25.  
  26.                     int current = (int)symb - 3;
  27.                     symb = (char)(current);
  28.                     descrypt.Append(symb);
  29.                 }
  30.                 else
  31.                 {
  32.                     Console.WriteLine("This is not the book you are looking for.");
  33.                     break;
  34.                 }
  35.  
  36.             }
  37.             string wordForDesc = descrypt.ToString();
  38.  
  39.             if (wordForDesc.Contains(previous))
  40.             {
  41.                 descrypt.Replace(previous, next);
  42.                 Console.Write(string.Join(" ", descrypt));
  43.             }
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement