Загрузка данных


#include <iostream>

using namespace std;

int main()
{
    int a, b, c, d, e;
    int F;
    int first;

    // =========================
    // Таблица истинности
    // =========================

    cout << "a b c d e | F" << endl;

    for (a = 0; a <= 1; a++)
    {
        for (b = 0; b <= 1; b++)
        {
            for (c = 0; c <= 1; c++)
            {
                for (d = 0; d <= 1; d++)
                {
                    for (e = 0; e <= 1; e++)
                    {
                        F = (a || !b || !c) && (d || !e);

                        cout << a << " ";
                        cout << b << " ";
                        cout << c << " ";
                        cout << d << " ";
                        cout << e << " | ";
                        cout << F << endl;
                    }
                }
            }
        }
    }


    // =========================
    // СДНФ
    // =========================

    cout << endl;
    cout << "SDNF:" << endl;

    first = 1;

    for (a = 0; a <= 1; a++)
    {
        for (b = 0; b <= 1; b++)
        {
            for (c = 0; c <= 1; c++)
            {
                for (d = 0; d <= 1; d++)
                {
                    for (e = 0; e <= 1; e++)
                    {
                        F = (a || !b || !c) && (d || !e);

                        if (F == 1)
                        {
                            if (first == 0)
                                cout << " || ";

                            cout << "(";

                            if (a == 0)
                                cout << "!a";
                            else
                                cout << "a";

                            cout << " && ";

                            if (b == 0)
                                cout << "!b";
                            else
                                cout << "b";

                            cout << " && ";

                            if (c == 0)
                                cout << "!c";
                            else
                                cout << "c";

                            cout << " && ";

                            if (d == 0)
                                cout << "!d";
                            else
                                cout << "d";

                            cout << " && ";

                            if (e == 0)
                                cout << "!e";
                            else
                                cout << "e";

                            cout << ")";

                            first = 0;
                        }
                    }
                }
            }
        }
    }


    // =========================
    // СКНФ
    // =========================

    cout << endl << endl;
    cout << "SKNF:" << endl;

    first = 1;

    for (a = 0; a <= 1; a++)
    {
        for (b = 0; b <= 1; b++)
        {
            for (c = 0; c <= 1; c++)
            {
                for (d = 0; d <= 1; d++)
                {
                    for (e = 0; e <= 1; e++)
                    {
                        F = (a || !b || !c) && (d || !e);

                        if (F == 0)
                        {
                            if (first == 0)
                                cout << " && ";

                            cout << "(";

                            if (a == 0)
                                cout << "a";
                            else
                                cout << "!a";

                            cout << " || ";

                            if (b == 0)
                                cout << "b";
                            else
                                cout << "!b";

                            cout << " || ";

                            if (c == 0)
                                cout << "c";
                            else
                                cout << "!c";

                            cout << " || ";

                            if (d == 0)
                                cout << "d";
                            else
                                cout << "!d";

                            cout << " || ";

                            if (e == 0)
                                cout << "e";
                            else
                                cout << "!e";

                            cout << ")";

                            first = 0;
                        }
                    }
                }
            }
        }
    }

    cout << endl;

    return 0;
}