Advertisement
Guest User

oneZero

a guest
Jan 25th, 2015
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.91 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace OnesAndZeroes
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int num = int.Parse(Console.ReadLine());
  14.             string numStr = Convert.ToString(num, 2);
  15.             char[] arr = numStr.ToCharArray();
  16.             string binary;
  17.             if (arr.Length > 16)
  18.             {
  19.                 char[] newArr = new char[16];
  20.                 Array.Reverse(arr);
  21.                 for (int i = 0; i < 16; i++)
  22.                 {
  23.                     newArr[i] = arr[i];
  24.                 }
  25.                 Array.Reverse(newArr);
  26.                 binary = new string(newArr);
  27.             }
  28.             else
  29.             {
  30.                 binary = new string(arr);
  31.                 binary = binary.PadLeft(16, '0');
  32.             }
  33.             string[] one = new string[5];
  34.             string[] zero = new string[5];
  35.             one[0] = ".#.";
  36.             one[1] = "##.";
  37.             one[2] = ".#.";
  38.             one[3] = ".#.";
  39.             one[4] = "###";
  40.             zero[0] = "###";
  41.             zero[1] = "#.#";
  42.             zero[2] = "#.#";
  43.             zero[3] = "#.#";
  44.             zero[4] = "###";
  45.  
  46.            
  47.             for (int i = 0; i < 5; i++)
  48.             {
  49.                 for (int j = 0; j < 16; j++)
  50.                 {
  51.                     int m = binary[j] - '0';
  52.                     if (m == 0)
  53.                     {
  54.                         Console.Write(zero[i]);
  55.                     }
  56.                     else if (m == 1)
  57.                     {
  58.                         Console.Write(one[i]);
  59.                     }
  60.                     if (j < 15)
  61.                     {
  62.                         Console.Write('.');
  63.                     }
  64.                 }
  65.                 Console.WriteLine();
  66.             }
  67.         }
  68.     }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement