Advertisement
kalinkata

MorseCodeNumbers

Jul 31st, 2014
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. class MorseCodeNumbers
  5. {
  6. static void Main()
  7. {
  8. int n = int.Parse(Console.ReadLine());
  9.  
  10. int nSum = (n % 10) + ((n % 100) / 10) +
  11. ((n % 1000) / 100) + (n / 1000);
  12.  
  13. Dictionary<int, string> nums = new Dictionary<int,string>();
  14. {
  15. nums[0] = "-----|";
  16. nums[1] = ".----|";
  17. nums[2] = "..---|";
  18. nums[3] = "...--|";
  19. nums[4] = "....-|";
  20. nums[5] = ".....|";
  21. }
  22.  
  23. bool check = false;
  24.  
  25. for (int num1 = 0; num1 <= 5; num1++)
  26. {
  27. for (int num2 = 0; num2 <= 5; num2++)
  28. {
  29. for (int num3 = 0; num3 <= 5; num3++)
  30. {
  31. for (int num4 = 0; num4 <= 5; num4++)
  32. {
  33. for (int num5 = 0; num5 <= 5; num5++)
  34. {
  35. for (int num6 = 0; num6 <= 5; num6++)
  36. {
  37. if (num1 * num2 * num3 * num4
  38. * num5 * num6 == nSum)
  39. {
  40. Console.WriteLine("{0}{1}{2}{3}{4}{5}",
  41. nums[num1], nums[num2], nums[num3],
  42. nums[num4], nums[num5], nums[num6]);
  43.  
  44. check = true;
  45. }
  46. }
  47. }
  48. }
  49. }
  50. }
  51. }
  52.  
  53. if (!check)
  54. {
  55. Console.WriteLine("No");
  56. }
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement