SHARE
TWEET

OnesAndZeros

g-stoyanov Apr 11th, 2014 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top