Advertisement
g-stoyanov

OnesAndZeros

Apr 11th, 2014
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.77 KB | None | 0 0
  1. namespace Task03OnesAndZeros
  2. {
  3.     using System;
  4.  
  5.     class Program
  6.     {
  7.         static void Main()
  8.         {
  9.             int number = int.Parse(Console.ReadLine());
  10.             string[,] matrix = new string[5, 2]
  11.             {
  12.                 {"###",".#."},
  13.                 {"#.#","##."},
  14.                 {"#.#",".#."},
  15.                 {"#.#",".#."},
  16.                 {"###","###"},
  17.             };
  18.  
  19.             for (int row = 0; row < 5; row++)
  20.             {
  21.                 for (int pos = 15; pos >= 0; pos--)
  22.                 {
  23.                     int bit = (number & (1 << pos)) >> pos;
  24.                     Console.Write("{0}{1}", matrix[row, bit], pos == 0 ? "" : ".");
  25.                 }
  26.  
  27.                 Console.WriteLine();
  28.             }
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement