Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _03_BitTower
- {
- class Program
- {
- static void Main(string[] args)
- {
- int input = int.Parse(Console.ReadLine());
- string bits = Convert.ToString(input, 2);
- bits = bits.PadLeft(16, '0');
- bits = bits.Substring(bits.Length - 16);
- char[,] bitZero =
- {
- {'#', '#', '#'},
- {'#', '.', '#'},
- {'#', '.', '#'},
- {'#', '#', '#'}
- };
- char[,] bitOne =
- {
- {'.', '#', '.'},
- {'#', '#', '.'},
- {'.', '#', '.'},
- {'#', '#', '#'}
- };
- int totalRows = 4;
- int totalCols = 63;
- int separator = 3;
- char[,] allBits = new char[totalRows, totalCols];
- //filling
- for (int row = 0; row < totalRows; row++)
- {
- for (int col = 0; col < totalCols; col++)
- {
- allBits[row, col] = '#';
- }
- }
- //separators
- for (int col = 0; col < totalCols; col++)
- {
- for (int row = 0; row < totalRows; row++)
- {
- if (col == separator)
- {
- allBits[row, col] = '.';
- allBits[row + 1, col] = '.';
- allBits[row + 2, col] = '.';
- allBits[row + 3, col] = '.';
- separator += 4;
- }
- }
- }
- //drawing numbers
- int singleBitCol = 0;
- int startCol = 0;
- for (int i = 0; i < bits.Length; i++)
- {
- if (bits[i] == '0')
- {
- for (int col = startCol; col < startCol + 3; col++)
- {
- for (int row = 0; row < totalRows; row++)
- {
- allBits[row, col] = bitZero[row, singleBitCol];
- }
- singleBitCol++;
- }
- singleBitCol = 0;
- }
- else if (bits[i] == '1')
- {
- for (int col = startCol; col < startCol + 3; col++)
- {
- for (int row = 0; row < totalRows; row++)
- {
- allBits[row, col] = bitOne[row, singleBitCol];
- }
- singleBitCol++;
- }
- singleBitCol = 0;
- }
- startCol += 4;
- }
- //for (int row = 0; row < totalRows; row++)
- //{
- // for (int col = 0; col < totalCols; col++)
- // {
- // }
- //}
- //printing
- for (int row = 0; row < totalRows; row++)
- {
- for (int col = 0; col < totalCols; col++)
- {
- Console.Write(allBits[row, col]);
- }
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement