aboutsummaryrefslogtreecommitdiff
Implementation of Gray code, multisets based on it, and operations on those multisets

Implementation of Gray code, multisets based on it, and operations on those multisets

1. Task1

Implement a program to generate Gray code for populating a universe (of a user‑specified bit length). Based on the universe, two multisets are formed using two methods of population: manually and automatically (the user chooses). The size of the sets is also set by the user. As a result, the results of all operations on the sets are displayed on the screen. In addition, protection against incorrect user input must be implemented.

2. Documentation

The exported report can be found at this link.

3. Showcase

Задайте разрядность универсума U ("^[[:digit:]]+$"): 3
[0] = 000 x 97
[1] = 001 x 67
[2] = 011 x 52
[3] = 010 x 50
[4] = 110 x 50
[5] = 111 x 16
[6] = 101 x 99
[7] = 100 x 71

Зададайте мощность мультимножества A ("^[[:digit:]]+$"): 2
Заполнить мультимножество автоматически (1) или вручную (2) ("^[12]$"): 1
[0] = 000 x 96
[1] = 101 x 35

Зададайте мощность мультимножества B ("^[[:digit:]]+$"): 3
Заполнить мультимножество автоматически (1) или вручную (2) ("^[12]$"): 1
[0] = 000 x 80
[1] = 011 x 16
[2] = 110 x 13

Объединение A и B:
[0] = 000 x 96
[1] = 011 x 16
[2] = 110 x 13
[3] = 101 x 35

Пересечение A и B:
[0] = 000 x 80

Дополнение A:
[0] = 000 x  1
[1] = 001 x 67
[2] = 011 x 52
[3] = 010 x 50
[4] = 110 x 50
[5] = 111 x 16
[6] = 101 x 64
[7] = 100 x 71

Дополнение B:
[0] = 000 x 17
[1] = 001 x 67
[2] = 011 x 36
[3] = 010 x 50
[4] = 110 x 37
[5] = 111 x 16
[6] = 101 x 99
[7] = 100 x 71

Разность A\B:
[0] = 000 x 16
[1] = 101 x 35

Разность B\A:
[0] = 000 x  0
[1] = 011 x 16
[2] = 110 x 13

Арифметическое сложение A и B:
[0] = 000 x 97
[1] = 011 x 16
[2] = 110 x 13
[3] = 101 x 35

Арифметическая разность A - B:
[0] = 000 x 16
[1] = 101 x 35

Арифметическая разность B - A:
[0] = 000 x  0
[1] = 011 x 16
[2] = 110 x 13

Арифметическое произведение A и B:
[0] = 000 x 97

Арифметическое деление A на B:
[0] = 000 x  1
[1] = 101 x 99

Арифметическое деление B на A:
[0] = 000 x 97
[1] = 011 x 52
[2] = 110 x 50

Симетрическая разность A и B:
[0] = 000 x 16
[1] = 011 x 16
[2] = 110 x 13
[3] = 101 x 35

4. Unlicense

This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.

In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to https://unlicense.org/

Footnotes:

1

Original text:

Реализовать программу генерации бинарного кода Грея для заполнения универсума (заданной пользователем разрядности). На основе универсума формируются два мультимножества двумя способами заполнения: вручную и автоматически (выбирает пользователь). Мощность множеств также задает пользователь. В результате на экран выводятся результаты всех действий над множествами. Кроме того, требуется реализовать защиту от некорректного пользовательского ввода.

Created: 2026-11-07 Sat 05:12