Advertisement
fbinnzhivko

04.01 MorseCode

May 13th, 2016
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.01 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. class Program
  4. {
  5.     static void Main()
  6.     {
  7.         int n = int.Parse(Console.ReadLine());
  8.  
  9.         bool found = false; int sumN = 0;
  10.  
  11.         List<int> a = new List<int>();
  12.  
  13.         while (n > 0)
  14.         {
  15.             sumN += n % 10;
  16.             n /= 10;
  17.         }
  18.         for (int i = 0; i < 6; i++)
  19.         {
  20.             for (int j = 0; j < 6; j++)
  21.             {
  22.                 for (int k = 0; k < 6; k++)
  23.                 {
  24.                     for (int l = 0; l < 6; l++)
  25.                     {
  26.                         for (int m = 0; m < 6; m++)
  27.                         {
  28.                             for (int o = 0; o < 6; o++)
  29.                             {
  30.                                 int g = i * j * k * l * m * o;
  31.  
  32.                                 if (g == sumN)
  33.                                 {
  34.                                     found = true;
  35.  
  36.                                     a.Add(i);
  37.                                     a.Add(j);
  38.                                     a.Add(k);
  39.                                     a.Add(l);
  40.                                     a.Add(m);
  41.                                     a.Add(o);
  42.  
  43.                                     for (int p = 0; p < a.Count; p++)
  44.                                     {
  45.                                         string r = null;
  46.  
  47.                                         if (a[p] == 0)
  48.                                         {
  49.                                             r = "-----";
  50.                                         }
  51.                                         else if (a[p] == 1)
  52.                                         {
  53.                                             r = ".----";
  54.                                         }
  55.                                         else if (a[p] == 2)
  56.                                         {
  57.                                             r = "..---";
  58.                                         }
  59.                                         else if (a[p] == 3)
  60.                                         {
  61.                                             r = "...--";
  62.                                         }
  63.                                         else if (a[p] == 4)
  64.                                         {
  65.                                             r = "....-";
  66.                                         }
  67.                                         else if (a[p] == 5)
  68.                                         {
  69.                                             r = ".....";
  70.                                         }
  71.  
  72.  
  73.                                         Console.Write("{0}|", r);
  74.                                     }
  75.  
  76.                                     a.Clear();
  77.                                     Console.WriteLine();
  78.                                 }
  79.                             }
  80.                         }
  81.                     }
  82.                 }
  83.             }
  84.         }
  85.  
  86.         if (!found)
  87.         {
  88.             Console.Write("No");
  89.         }
  90.     }
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement