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 Test
- {
- class Program
- {
- static void Main(string[] args)
- {
- int dec = 1000;
- String result = "";
- while (dec > 0)
- {
- int bin = dec % 2;
- dec /= 2;
- result = bin + result;
- }
- Console.WriteLine(result);
- Console.WriteLine(result.Length);
- while (result.Length % 4 != 0)
- {
- result = "0" + result;
- }
- Console.WriteLine(result);
- Console.WriteLine(result.Length);
- int count = 0;
- for (int i = 0; i < result.Length; i++)
- {
- if (count == 4)
- {
- result = result.Insert(i, " ");
- count = 0;
- }
- if (result[i].ToString() != " ")
- {
- count++;
- }
- }
- Console.WriteLine(result);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement