mellowdeep

DNA

Dec 7th, 2015
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.90 KB | None | 0 0
  1. using System;
  2.  
  3. class ProgrammerDNA
  4. {
  5.     public static char[] letters = new char[7];
  6.  
  7.     static void Main()
  8.     {
  9.         int size = int.Parse(Console.ReadLine());
  10.         char ch = char.Parse(Console.ReadLine());
  11.         int asciiCode = Convert.ToInt32(ch);
  12.         FillArrayOfChars(asciiCode);
  13.      
  14.         bool direction = true;
  15.         int symbol = 0;
  16.         int dot = 3;
  17.      
  18.         for(int row = 0,diamond = 0; row < size; row++,diamond++)
  19.         {
  20.             if(diamond != 0 && diamond % 7 == 0)
  21.             {
  22.                if (symbol == 7)
  23.                {
  24.                  symbol = 0;
  25.                }
  26.                Console.WriteLine("{0}{1}{0}", new string('.',3),letters[symbol]);
  27.                symbol++;
  28.                continue;
  29.             }
  30.             Console.Write("{0}", new string('.',dot));
  31.            
  32.             for(int col = 0;col < 7-dot*2; col++)
  33.             {
  34.                if (symbol == 7)
  35.                {
  36.                  symbol = 0;
  37.                }
  38.                Console.Write("{0}",letters[symbol]);
  39.                symbol++;
  40.             }
  41.           Console.Write("{0}", new string('.',dot));
  42.           Console.WriteLine();
  43.          
  44.           if(direction)
  45.           {
  46.             if(dot == 0)
  47.             {
  48.               direction = false;
  49.               dot++;
  50.               continue;
  51.             }
  52.             dot--;
  53.           }
  54.           if(!direction)
  55.           {
  56.             if(dot == 3)
  57.             {
  58.               direction = true;
  59.               dot--;
  60.               continue;
  61.             }
  62.             dot++;
  63.           }
  64.         }
  65.     }
  66.     private static void FillArrayOfChars(int charNum)
  67.     {
  68.         for (int i = 0; i < 7; i++)
  69.         {
  70.             if (charNum == 72)
  71.             {
  72.                 charNum = 65;
  73.             }
  74.             letters[i] = (char)(charNum);
  75.             charNum++;
  76.         }
  77.     }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment