Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <Windows.h>
- using namespace std;
- int otrPosta(int x, int k)
- {
- return (x + 1) % k;
- }
- int otrLucas(int x, int k)
- {
- return (k - 1) - x;
- }
- int minusX(int x, int k)
- {
- return (k - x) % k;
- }
- int min1(int x, int y)
- {
- if (x <= y) return x;
- else return y;
- }
- int max1(int x, int y)
- {
- if (x >= y) return x;
- else return y;
- }
- int usRazn(int x, int y)
- {
- if (x >= y) return x - y;
- else return 0;
- }
- int impl(int x, int y, int k)
- {
- if (x <= y) return k - 1;
- else return (k - 1) - (x - y);
- }
- int add2(int x, int y, int k)
- {
- return (x + y) % k;
- }
- int check(int x)
- {
- int c = 0;
- while (x != 0)
- {
- c++;
- x /= 10;
- }
- return c;
- }
- void str(int x)
- {
- for (int i = 0; i < 52; i++) cout << "-";
- if (check(x) == 2) cout << "-";
- if (check(x) == 3) cout << "--";
- if (check(x) == 4) cout << "---";
- if (check(x) == 5) cout << "----";
- }
- int main()
- {
- HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
- SetConsoleTextAttribute(hConsole, (WORD)((0 << 4) | 15));
- setlocale(LC_ALL, "RUS");
- cout << "Введите значение k:\nk = ";
- int k;
- cin >> k;
- while (k < 1)
- {
- cout << "Введите целое положительное число!\nk = ";
- cin >> k;
- }
- cout << "\n1. Отрицание Поста (для х)\n";
- cout << "2. Отрицание Поста (для у)\n";
- cout << "3. Отрицание Лукасевича (для х)\n";
- cout << "4. Отрицание Лукасевича (для у)\n";
- cout << "5. Минус Х (для х)\n";
- cout << "6. Минус Х (для у)\n";
- cout << "7. Мin\n";
- cout << "8. Мax\n";
- cout << "9. Усечённая разность\n";
- cout << "10. Импликация\n";
- cout << "11. Сложение по модулю k\n";
- int x = 0, y = 0;
- str(x);
- SetConsoleTextAttribute(hConsole, (WORD)((0 << 4) | 9));
- cout.width(3);
- cout << "\n| x|";
- cout.width(3);
- cout << " y|";
- cout.width(3);
- cout << " 1|";
- cout.width(3);
- cout << " 2|";
- cout.width(3);
- cout << " 3|";
- cout.width(3);
- cout << " 4|";
- cout.width(3);
- cout << " 5|";
- cout.width(3);
- cout << " 6|";
- cout.width(3);
- cout << " 7|";
- cout.width(3);
- cout << " 8|";
- cout.width(3);
- cout << " 9|";
- cout.width(3);
- cout << " 10|";
- cout.width(3);
- cout << " 11|\n";
- SetConsoleTextAttribute(hConsole, (WORD)((0 << 4) | 15));
- while (x != k)
- {
- while (y != k)
- {
- str(x);
- cout.width(3);
- cout << "\n| ";
- SetConsoleTextAttribute(hConsole, (WORD)((0 << 4) | 12));
- cout << x;
- SetConsoleTextAttribute(hConsole, (WORD)((0 << 4) | 15));
- cout << "|";
- cout.width(3);
- SetConsoleTextAttribute(hConsole, (WORD)((0 << 4) | 12));
- cout << y;
- SetConsoleTextAttribute(hConsole, (WORD)((0 << 4) | 15));
- cout << "|";
- cout.width(3);
- cout << otrPosta(x, k) << "|";
- cout.width(3);
- cout << otrPosta(y, k) << "|";
- cout.width(3);
- cout << otrLucas(x, k) << "|";
- cout.width(3);
- cout << otrLucas(y, k) << "|";
- cout.width(3);
- cout << minusX(x, k) << "|";
- cout.width(3);
- cout << minusX(y, k) << "|";
- cout.width(3);
- cout << min1(x, y) << "|";
- cout.width(3);
- cout << max1(x, y) << "|";
- cout.width(3);
- cout << usRazn(x, y) << "|";
- cout.width(3);
- cout << impl(x, y, k) << "|";
- cout.width(3);
- cout << add2(x, y, k) << "|\n";
- y++;
- }
- y = 0;
- x++;
- }
- str(x);
- cout << '\n';
- system("pause");
- return 0;
- }
Add Comment
Please, Sign In to add comment