• Плиз, кто разбирается в программировании, помогите написать код на C#.
    Задание на картинке

    question img

Ответы 1

  • using System;using System.Linq;using System.Numerics;class Program{    public static readonly char[] hex_chars = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };    static void Main()    {        var random = new Random(DateTime.Now.Millisecond);        var long_hex = new char[random.Next(10, 255)];        for (var i = 0; i < long_hex.Length; i++)        {            long_hex[i] = hex_chars[random.Next(0, 15)];            Console.Write(long_hex[i] + " ");        }        Console.WriteLine();        LongHexToNumber(long_hex);        Console.ReadKey();    }    static void LongHexToNumber(char[] long_hex)    {        var s = long_hex.Aggregate("", (xs, x) => x + xs);        var number = BigInteger.Parse(s, System.Globalization.NumberStyles.AllowHexSpecifier);        Console.WriteLine("Число = {0}", number);        Console.WriteLine("Число(HEX) = {0:X}", number);        Console.WriteLine("Входит в диапазон int: {0}", int.MaxValue >= number && int.MinValue <= number);        Console.WriteLine("Входит в диапазон uint: {0}", uint.MaxValue >= number && uint.MinValue <= number);        Console.WriteLine("Входит в диапазон long: {0}", long.MaxValue >= number && long.MinValue <= number);        Console.WriteLine("Входит в диапазон ulong: {0}", ulong.MaxValue >= number && ulong.MinValue <= number);    }}Только еще надо подключить библиотеку System.Numerics.dllДля этого надо в проекте найти Reference, правой кнопкой -> Add Reference (откроется окошко) и там в стандартных библиотеках найти нужную  
    • Автор:

      mollyw6oo
    • 6 лет назад
    • 0
  • Добавить свой ответ

Еще вопросы

Войти через Google

или

Забыли пароль?

У меня нет аккаунта, я хочу Зарегистрироваться

How much to ban the user?
1 hour 1 day 100 years