Advertisement
Guest User

Untitled

a guest
Dec 6th, 2013
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.30 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 _03_BitTower
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int input = int.Parse(Console.ReadLine());
  14.  
  15.             string bits = Convert.ToString(input, 2);
  16.             bits = bits.PadLeft(16, '0');
  17.             bits = bits.Substring(bits.Length - 16);
  18.             char[,] bitZero =
  19.             {
  20.                 {'#', '#', '#'},
  21.                 {'#', '.', '#'},
  22.                 {'#', '.', '#'},
  23.                 {'#', '#', '#'}
  24.             };
  25.  
  26.             char[,] bitOne =
  27.             {
  28.                 {'.', '#', '.'},
  29.                 {'#', '#', '.'},
  30.                 {'.', '#', '.'},
  31.                 {'#', '#', '#'}
  32.             };
  33.  
  34.             int totalRows = 4;
  35.             int totalCols = 63;
  36.             int separator = 3;
  37.             char[,] allBits = new char[totalRows, totalCols];
  38.  
  39.             //filling
  40.             for (int row = 0; row < totalRows; row++)
  41.             {
  42.                 for (int col = 0; col < totalCols; col++)
  43.                 {
  44.                     allBits[row, col] = '#';
  45.                 }
  46.             }
  47.  
  48.             //separators
  49.             for (int col = 0; col < totalCols; col++)
  50.             {
  51.                 for (int row = 0; row < totalRows; row++)
  52.                 {
  53.                     if (col == separator)
  54.                     {
  55.                         allBits[row, col] = '.';
  56.                         allBits[row + 1, col] = '.';
  57.                         allBits[row + 2, col] = '.';
  58.                         allBits[row + 3, col] = '.';
  59.                         separator += 4;
  60.                     }
  61.                 }
  62.  
  63.             }
  64.  
  65.             //drawing numbers
  66.             int singleBitCol = 0;
  67.             int startCol = 0;
  68.             for (int i = 0; i < bits.Length; i++)
  69.             {
  70.  
  71.                 if (bits[i] == '0')
  72.                 {
  73.                     for (int col = startCol; col < startCol + 3; col++)
  74.                     {
  75.                         for (int row = 0; row < totalRows; row++)
  76.                         {
  77.                             allBits[row, col] = bitZero[row, singleBitCol];
  78.                         }
  79.                         singleBitCol++;
  80.  
  81.                     }
  82.  
  83.                     singleBitCol = 0;
  84.                 }
  85.  
  86.  
  87.                 else if (bits[i] == '1')
  88.                 {
  89.                     for (int col = startCol; col < startCol + 3; col++)
  90.                     {
  91.                         for (int row = 0; row < totalRows; row++)
  92.                         {
  93.                             allBits[row, col] = bitOne[row, singleBitCol];
  94.                         }
  95.                         singleBitCol++;
  96.  
  97.                     }
  98.                     singleBitCol = 0;
  99.                 }
  100.                 startCol += 4;
  101.             }
  102.  
  103.             //for (int row = 0; row < totalRows; row++)
  104.             //{
  105.             //    for (int col = 0; col < totalCols; col++)
  106.             //    {
  107.  
  108.             //    }
  109.             //}
  110.  
  111.             //printing
  112.             for (int row = 0; row < totalRows; row++)
  113.             {
  114.                 for (int col = 0; col < totalCols; col++)
  115.                 {
  116.                     Console.Write(allBits[row, col]);
  117.                 }
  118.                 Console.WriteLine();
  119.             }
  120.  
  121.         }
  122.     }
  123. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement