BorisSimeonov

Magic Car Numbers

Nov 7th, 2014
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.63 KB | None | 0 0
  1. using System;
  2.  
  3. class MagicCarNumbers
  4. {
  5.     static void Main()
  6.     {
  7.         int magNum = int.Parse(Console.ReadLine());
  8.         int startValue = 40;
  9.         int[] charValues = {10,20,30,50,80,110, 130,160, 200, 240 };
  10.         int counter = 0;
  11.         //char first;
  12.         //char second;
  13.         //++++++++++++++++++++++++++++
  14.         for (int fst = 0; fst <= 9; fst++ )
  15.         {
  16.             for (int snd = 0; snd <= 9; snd++)
  17.             {
  18.                 for (int trd = 0; trd <= 9; trd++)
  19.                 {
  20.                     for (int fth = 0; fth <= 9; fth++)
  21.                     {
  22.                         //Chars
  23.                         for (int fstLett = 0; fstLett < 10; fstLett++ )
  24.                         {
  25.                             for (int sndLett = 0; sndLett < 10; sndLett++ )
  26.                             {
  27.                                 if (startValue + fst + snd + trd + fth +
  28.                                     charValues[fstLett] + charValues[sndLett] == magNum)
  29.                                 {
  30.                                     if((fst == snd && snd == trd) || (snd == trd && trd == fth) ||
  31.                                         (fst == trd && snd == fth) || (fst == snd && snd == trd && trd == fth) ||
  32.                                         (fst == snd && trd == fth) || (fst == fth && snd == trd))
  33.                                     {
  34.                                         /*first = checkChar(charValues[fstLett]);
  35.                                         second = checkChar(charValues[sndLett]);
  36.                                         Console.WriteLine("CA{0}{1}{2}{3}{4}{5}", fst, snd, trd, fth, first, second);*/
  37.                                         counter++;
  38.                                     }
  39.                                 }
  40.                             }
  41.                         }
  42.                     }
  43.                 }
  44.             }
  45.         }
  46.         Console.WriteLine(counter);
  47.     }
  48.  
  49.     /*private static char checkChar(int p)
  50.     {
  51.         char x = new char();
  52.         switch (p)
  53.         {
  54.             case 10: x = 'A';
  55.                 break;
  56.             case 20: x = 'B';
  57.                 break;
  58.             case 30: x = 'C';
  59.                 break;
  60.             case 50: x = 'E';
  61.                 break;
  62.             case 80: x = 'H';
  63.                 break;
  64.             case 110: x = 'K';
  65.                 break;
  66.             case 130: x = 'M';
  67.                 break;
  68.             case 160: x = 'P';
  69.                 break;
  70.             case 200: x = 'T';
  71.                 break;
  72.             case 240: x = 'X';
  73.                 break;
  74.         }
  75.         return x;
  76.     }*/
  77. }
Advertisement
Add Comment
Please, Sign In to add comment