Advertisement
Guest User

test

a guest
Mar 2nd, 2015
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 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 Test
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int dec = 1000;
  14. String result = "";
  15.  
  16. while (dec > 0)
  17. {
  18. int bin = dec % 2;
  19. dec /= 2;
  20. result = bin + result;
  21. }
  22.  
  23. Console.WriteLine(result);
  24. Console.WriteLine(result.Length);
  25. while (result.Length % 4 != 0)
  26. {
  27. result = "0" + result;
  28. }
  29. Console.WriteLine(result);
  30. Console.WriteLine(result.Length);
  31.  
  32. int count = 0;
  33. for (int i = 0; i < result.Length; i++)
  34. {
  35. if (count == 4)
  36. {
  37. result = result.Insert(i, " ");
  38. count = 0;
  39. }
  40.  
  41. if (result[i].ToString() != " ")
  42. {
  43. count++;
  44. }
  45. }
  46.  
  47. Console.WriteLine(result);
  48.  
  49. }
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement