Си диез / Говнокод #12558 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
  43. 43
  44. 44
  45. 45
  46. 46
  47. 47
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace ConsoleApplication49
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Введите 16-ричное число(не более 32 знаков)");
            string s = Console.ReadLine();
            string result = "";
            string t = "123456789abcdef0";
            int i = 0;
            char[] a = new char[32];
            a = s.ToCharArray();
            char[] b = new char[16];
            b = t.ToCharArray();
            while (i<a.Length) 
             {
                 if (a[i] != b[0]) ; else result += "0001";
                 if (a[i] != b[1]) ; else result += "0010";
                 if (a[i] != b[2]) ; else result += "0011";
                 if (a[i] != b[3]) ; else result += "0100";
                 if (a[i] != b[4]) ; else result += "0101";
                 if (a[i] != b[5]) ; else result += "0110";
                 if (a[i] != b[6]) ; else result += "0111";
                 if (a[i] != b[7]) ; else result += "1000";
                 if (a[i] != b[8]) ; else result += "1001";
                 if (a[i] != b[9]) ; else result += "1010";
                 if (a[i] != b[10]) ; else result += "1011";
                 if (a[i] != b[11]) ; else result += "1100";
                 if (a[i] != b[12]) ; else result += "1101";
                 if (a[i] != b[13]) ; else result += "1110";
                 if (a[i] != b[14]) ; else result += "1111";
                 if (a[i] != b[15]) ; else result += "0000";
                 i++;
             };
             Console.WriteLine("{0} в двоичном виде выглядит так {1}",s,result);
             
            Console.ReadKey();
        
        }
    }
}

Перевод из 16ричной в двоичную СС

Запостил: Psilon Psilon, (Updated )

Комментарии (30) RSS

Добавить комментарий

Из-за тебя ушел bormand, guest!

    А не использовать ли нам bbcode?


    8