Advertisement
Guest User

Problem 2 – Detective Boev

a guest
Sep 24th, 2016
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. class Program
  4. {
  5. static void Main()
  6. {
  7. string secretWord = Console.ReadLine();
  8. string encryptedMessage = Console.ReadLine();
  9. int result = 0;
  10. int mask = 0;
  11.  
  12. foreach (char c in secretWord)
  13. {
  14. if (c > 0 || c <= 99)
  15. {
  16. mask += c % 10 + c / 10;
  17. }
  18. else if (c >= 100 || c <= 999)
  19. {
  20. int edinici = c % 10;
  21. int desetici = (c - (c % 10)) / 100;
  22. int stotici = c / 100;
  23. mask += edinici + desetici + stotici;
  24. }
  25. }
  26. for (int i = 0; i < encryptedMessage.Length; i++)
  27. {
  28. foreach (char a in encryptedMessage)
  29. {
  30. result += a;
  31. if (i % mask == 0)
  32. {
  33. result += mask;
  34. }
  35. else
  36. {
  37. result -= mask;
  38. }
  39. }
  40. }
  41. Console.WriteLine(Convert.ToChar(result));
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement