Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text;
- class Program
- {
- static void Main()
- {
- long number = 4095;//65535;// int.Parse(Console.ReadLine());
- //Console.WriteLine(GetIntBinaryString (number));
- string bin = GetIntBinaryString(number).ToString();
- char[] numBin = new char[16];
- numBin= bin.ToCharArray();//Convert.ToString(number, 2).PadLeft(16, '0').ToCharArray();//
- string[] zeroes = new string[]{
- "###",
- "#.#",
- "#.#",
- "#.#",
- "###"};
- string[] once = new string[] {
- ".#.",
- "##.",
- ".#.",
- ".#.",
- "###" };
- int lineCounter = 0;
- StringBuilder line = new StringBuilder();
- while (lineCounter < zeroes.Length)
- {
- for (int i = 0; i < numBin.Length; i++)
- {
- if (numBin[i] == '1')
- {
- line.Append(once[lineCounter]);
- if (i < numBin.Length - 1)
- {
- line.Append(".");
- }
- }
- else if (numBin[i] == '0')
- {
- line.Append(zeroes[lineCounter]);
- if (i < numBin.Length - 1)
- {
- line.Append(".");
- }
- }
- }
- Console.WriteLine(line);
- line.Clear();
- lineCounter++;
- }
- }
- static string GetIntBinaryString(long n)
- {
- char[] b = new char[16];
- int pos = 15;
- int i = 0;
- while (i < 16)
- {
- if ((n & (1 << i)) != 0)
- {
- b[pos] = '1';
- }
- else
- {
- b[pos] = '0';
- }
- pos--;
- i++;
- }
- return new string(b);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement