Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Program
- {
- static void Main()
- {
- int n = int.Parse(Console.ReadLine());
- string bin = "";
- string tempstring = "";
- int counter = 0;
- while (n > 0)
- {
- tempstring += n % 2 + "";
- n /= 2;
- if (n == 1)
- {
- tempstring += '1';
- break;
- }
- }
- //reversing the string
- for (int i = tempstring.Length - 1; i >= 0; i--)
- {
- if (counter % 4 ==0 && counter!=0)
- {
- bin += " ";
- }
- bin += tempstring[i];
- counter++;
- }
- Console.WriteLine(bin);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement