Advertisement
ivanov_ivan

Detective Boev

Oct 31st, 2015
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.45 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 FourFactors
  8.     {
  9.     class DetectiveBoev
  10.         {
  11.         static void Main()
  12.             {
  13.             string secretWord = Console.ReadLine();
  14.             string encrypMess = Console.ReadLine();
  15.             int count = 0;
  16.             foreach (char item in secretWord)
  17.                 {
  18.                 count += (int)item;
  19.                 }
  20.             string countString = count.ToString();
  21.             count = 0;
  22.             while (countString.Length > 1)
  23.                 {
  24.                 foreach (var item in countString)
  25.                     {
  26.                     count += (int)char.GetNumericValue(item);
  27.                     }
  28.                 countString = count.ToString();
  29.                 count = 0;
  30.                 }
  31.             count = int.Parse(countString);
  32.             string decrMess = null;
  33.             foreach (var item in encrypMess)
  34.                 {
  35.                 if (item % count == 0)
  36.                     {
  37.                     decrMess += (char)(item + count);
  38.                     }
  39.                 else
  40.                     {
  41.                     decrMess += (char)(item - count);
  42.                     }
  43.                 }
  44.             string decrMessRev = new string(decrMess.ToCharArray().Reverse().ToArray());
  45.             Console.WriteLine(decrMessRev);
  46.             }
  47.         }
  48.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement