Esempio n. 1
0
        static void Main()
        {
            Console.WriteLine("Введите строку из '0' и '1' длины " + Coder.TextLength);
            var text = Console.ReadLine();
            var code = Coder.Code(text);

            Console.WriteLine("Код этой строки: " + code);
            Console.WriteLine("Введите номер позиции, в которой произошла ошибка, либо 0, если ошибки не было");
            // ReSharper disable once AssignNullToNotNullAttribute
            var errorPosition = int.Parse(Console.ReadLine());

            if (errorPosition != 0)
            {
                errorPosition--;
                var d = code[errorPosition] - '0';
                d   ^= 1;
                code = code.Remove(errorPosition, 1).Insert(errorPosition, d.ToString());
                Console.WriteLine("Код с ошибкой: " + code);
                code = Coder.CorrectError(code);
                Console.WriteLine("Исправленный код: " + code);
            }

            text = Coder.Decode(code);
            Console.WriteLine("Раскодированный текст: " + text);
            Console.ReadKey();
        }