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 message = Console.ReadLine();
- int sum = 0;
- for (int i = 0; i < secretWord.Length; i++)
- {
- sum += (int)secretWord[i];
- }
- while (sum /10 != 0)
- {
- int newSum = 0;
- while (sum > 0)
- {
- newSum += sum % 10;
- sum /= 10;
- }
- sum = newSum;
- }
- StringBuilder str = new StringBuilder(message);
- for (int i = 0; i < str.Length; i++)
- {
- if (str[i] % sum == 0)
- {
- str[i] = (char)((int)str[i] + sum);
- }
- else
- {
- str[i] = (char)((int)str[i] - sum);
- }
- }
- message = str.ToString();
- char[] arr = message.ToCharArray();
- Array.Reverse(arr);
- Console.WriteLine(new string(arr));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement