Advertisement
nmnikolov

04. MorseCodeNumbers

Jul 25th, 2014
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.49 KB | None | 0 0
  1. using System;
  2.  
  3. class MorseCodeNumbers
  4. {
  5.     static void Main()
  6.     {
  7.         int n = int.Parse(Console.ReadLine());
  8.         string[] morse = {"-----", ".----", "..---", "...--", "....-", "....." };
  9.         int nSum = 0;
  10.         int count = 0;
  11.         int product = 0;
  12.         string c = "|";
  13.  
  14.         for (int i = 0; i < 4; i++)
  15.         {
  16.             nSum += n % 10;
  17.             n = n / 10;
  18.         }
  19.         for (int i0 = 0; i0 < 6; i0++)
  20.         {
  21.             for (int i1 = 0; i1 < 6; i1++)
  22.             {
  23.                 for (int i2 = 0; i2 < 6; i2++)
  24.                 {
  25.                     for (int i3 = 0; i3 < 6; i3++)
  26.                     {
  27.                         for (int i4 = 0; i4 < 6; i4++)
  28.                         {
  29.                             for (int i5 = 0; i5 < 6; i5++)
  30.                             {
  31.                                 product = i0 * i1 * i2 * i3 * i4 * i5;
  32.                                 if (product == nSum)
  33.                                 {
  34.                                     string output = morse[i0] + c + morse[i1] + c + morse [i2] + c + morse[i3] + c + morse[i4] + c + morse[i5] + c;
  35.                                     Console.WriteLine(output.Trim());
  36.                                     count++;
  37.                                 }
  38.                             }
  39.                         }
  40.                     }
  41.                 }
  42.             }
  43.         }
  44.  
  45.         if (count == 0)
  46.         {
  47.             Console.WriteLine("No");
  48.         }
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement