Advertisement
Filkolev

MorseCode - corrected

Aug 2nd, 2014
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.59 KB | None | 0 0
  1. using System;
  2.  
  3. class MorseCodeNums
  4. {
  5.     static void Main()
  6.     {
  7.         string input = Console.ReadLine();
  8.         int[] inputInt = new int[input.Length];
  9.         int nSum = 0;
  10.         int matchings = 0;
  11.  
  12.         for (int i = 0; i < input.Length; i++)
  13.         {
  14.             inputInt[i] = Convert.ToInt32(input[i].ToString());
  15.             nSum += inputInt[i];
  16.         }
  17.  
  18.      
  19.         int morseCodeProduct = 0;
  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.                             for (int i6 = 0; i6 < 6; i6++)
  32.                             {
  33.                                 morseCodeProduct = i1 * i2 * i3 * i4 * i5 * i6;
  34.                                 if (morseCodeProduct == nSum)
  35.                                 {
  36.                                     Console.Write(new string('.', i1));
  37.                                     Console.Write(new string('-', 5 - i1));
  38.                                     Console.Write("|");
  39.                                     Console.Write(new string('.', i2));
  40.                                     Console.Write(new string('-', 5 - i2));
  41.                                     Console.Write("|");
  42.                                     Console.Write(new string('.', i3));
  43.                                     Console.Write(new string('-', 5 - i3));
  44.                                     Console.Write("|");
  45.                                     Console.Write(new string('.', i4));
  46.                                     Console.Write(new string('-', 5 - i4));
  47.                                     Console.Write("|");
  48.                                     Console.Write(new string('.', i5));
  49.                                     Console.Write(new string('-', 5 - i5));
  50.                                     Console.Write("|");
  51.                                     Console.Write(new string('.', i6));
  52.                                     Console.Write(new string('-', 5 - i6));
  53.                                     Console.Write("|");
  54.                                     Console.WriteLine();
  55.                                     matchings++;
  56.                                 }
  57.                             }
  58.                         }
  59.                     }
  60.                 }
  61.             }
  62.         }
  63.         if (matchings == 0)
  64.         {
  65.             Console.WriteLine("No");
  66.         }
  67.  
  68.     }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement