Advertisement
EvstatiZarkov

C# Exam April 2014 - Programer DNA

Apr 16th, 2014
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.79 KB | None | 0 0
  1. using System;
  2.  
  3. class ProgramerDNA
  4. {
  5.     static void Main()
  6.     {
  7.         char[] dna = { 'A', 'B', 'C', 'D', 'E', 'F', 'G' };
  8.  
  9.         int length = int.Parse(Console.ReadLine());
  10.         char startingLetter = char.Parse(Console.ReadLine());
  11.         int dnaindex = startingLetter - 65;
  12.         for (int i = 0; i < length; i++)
  13.         {
  14.             int row = i % 7 + 1;
  15.  
  16.             switch (row)
  17.             {
  18.                 case 1: Console.WriteLine("{0}{1}{0}", new string('.', 3), dna[dnaindex % 7]); dnaindex++; break;
  19.                 case 2: Console.WriteLine("{0}{1}{2}{3}{0}", new string('.', 2), dna[dnaindex % 7], dna[(dnaindex + 1) % 7], dna[(dnaindex + 2) % 7]); dnaindex += 3; break;
  20.                 case 3: Console.WriteLine("{0}{1}{2}{3}{4}{5}{0}", new string('.', 1), dna[dnaindex % 7], dna[(dnaindex + 1) % 7], dna[(dnaindex + 2) % 7], dna[(dnaindex + 3) % 7], dna[(dnaindex + 4) % 7]); dnaindex = dnaindex + 5; break;
  21.                 case 4: Console.WriteLine("{0}{1}{2}{3}{4}{5}{6}", dna[dnaindex % 7], dna[(dnaindex + 1) % 7], dna[(dnaindex + 2) % 7], dna[(dnaindex + 3) % 7], dna[(dnaindex + 4) % 7], dna[(dnaindex + +5) % 7], dna[(dnaindex + 6) % 7]); dnaindex = dnaindex + 7; break;
  22.                 case 5: Console.WriteLine("{0}{1}{2}{3}{4}{5}{0}", new string('.', 1), dna[dnaindex % 7], dna[(dnaindex + 1) % 7], dna[(dnaindex + 2) % 7], dna[(dnaindex + 3) % 7], dna[(dnaindex + 4) % 7]); dnaindex = dnaindex + 5; break;
  23.                 case 6: Console.WriteLine("{0}{1}{2}{3}{0}", new string('.', 2), dna[dnaindex % 7], dna[(dnaindex + 1) % 7], dna[(dnaindex + 2) % 7]); dnaindex += 3; break;
  24.                 case 7: Console.WriteLine("{0}{1}{0}", new string('.', 3), dna[dnaindex % 7]); dnaindex = dnaindex + 1; break;
  25.                 default: ; break;
  26.             }
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement