Advertisement
Guest User

04

a guest
Jul 25th, 2014
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.85 KB | None | 0 0
  1. using System;
  2.  
  3. class Program
  4. {
  5.     static void Main()
  6.     {
  7.         string n = Console.ReadLine().Trim();
  8.         bool foundSolution = false;
  9.         int nSum = 0;
  10.  
  11.         foreach (char number in n.ToCharArray())
  12.         {
  13.             nSum += Convert.ToInt32(number.ToString());
  14.         }
  15.  
  16.         for (int i1 = 0; i1 < 6; i1++)
  17.         {
  18.             for (int i2 = 0; i2 < 6; i2++)
  19.             {
  20.                 for (int i3 = 0; i3 < 6; i3++)
  21.                 {
  22.                     for (int i4 = 0; i4 < 6; i4++)
  23.                     {
  24.                         for (int i5 = 0; i5 < 6; i5++)
  25.                         {
  26.                             for (int i6 = 0; i6 < 6; i6++)
  27.                             {
  28.                                 if(i1 * i2 * i3 * i4 * i5 * i6 == nSum)
  29.                                 {
  30.                                     foundSolution = true;
  31.  
  32.                                     Console.WriteLine("{0}|{1}|{2}|{3}|{4}|{5}|", MorseCode(i1), MorseCode(i2), MorseCode(i3), MorseCode(i4), MorseCode(i5), MorseCode(i6));
  33.                                 }
  34.                             }
  35.                         }
  36.                     }
  37.                 }
  38.             }
  39.         }
  40.  
  41.         if(!foundSolution)
  42.         {
  43.             Console.WriteLine("No");
  44.         }
  45.     }
  46.  
  47.     static string MorseCode(int n)
  48.     {
  49.         string code = "";
  50.  
  51.         if(n == 0)
  52.         {
  53.             code = "-----";
  54.         }
  55.         else if (n == 1)
  56.         {
  57.             code = ".----";
  58.         }
  59.         else if (n == 2)
  60.         {
  61.             code = "..---";
  62.         }
  63.         else if (n == 3)
  64.         {
  65.             code = "...--";
  66.         }
  67.         else if (n == 4)
  68.         {
  69.             code = "....-";
  70.         }
  71.         else if (n == 5)
  72.         {
  73.             code = ".....";
  74.         }
  75.  
  76.         return code;
  77.     }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement