Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- class DetectiveBoev
- {
- static void Main()
- {
- string secretWord = Console.ReadLine();
- string encryptedMessage = Console.ReadLine();
- int mask = 0;
- for (int i = 0; i < secretWord.Length; i++)
- {
- mask += secretWord[i];
- }
- while (mask > 9)
- {
- mask = CalcMask(mask);
- }
- char[] arr = encryptedMessage.ToCharArray();
- for (int i = 0; i < arr.Length; i++)
- {
- if (arr[i] % mask == 0)
- {
- arr[i] = (char)(arr[i] + mask);
- }
- else
- {
- arr[i] = (char)(arr[i] - mask);
- }
- }
- arr = arr.Reverse().ToArray();
- Console.WriteLine(new string(arr));
- }
- private static int CalcMask(int mask)
- {
- int sum = 0;
- while (mask > 0)
- {
- sum += mask % 10;
- mask = mask / 10;
- }
- return sum;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement