Advertisement
skipter

C# Fundamentals - DNA sequences / for + if loops

Jun 8th, 2017
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.17 KB | None | 0 0
  1. using System;
  2. namespace p._6_DNA_Sequences
  3. {
  4.     class Program
  5.     {
  6.         static void Main(string[] args)
  7.         {
  8.             int matchSum = int.Parse(Console.ReadLine());
  9.  
  10.             for (int firstChar = 1; firstChar <= 4; firstChar++)
  11.             {
  12.                 for (int secondChar = 1; secondChar  <= 4; secondChar++)
  13.                 {
  14.                     for (int thirdChar = 1; thirdChar <= 4; thirdChar++)
  15.                     {
  16.                         string result = $"{firstChar}{secondChar}{thirdChar}";
  17.                         result = result.Replace("1", "A").Replace("2", "C").Replace("3", "G").Replace("4", "T");
  18.  
  19.                         if (firstChar + secondChar + thirdChar >= matchSum)
  20.                         {
  21.                             Console.Write($"O{result}O ");
  22.                         } else
  23.                         {
  24.                             Console.Write($"X{result}X ");
  25.                         }
  26.                         if (thirdChar % 4 == 0)
  27.                         {
  28.                             Console.WriteLine();
  29.                         }
  30.  
  31.                     }
  32.                 }
  33.             }
  34.         }  
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement