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


#include <iostream>
#include <fstream>
#include <string>

using namespace std;

struct Node
{
    char data;
    Node* next;
};

void push(Node*& top, char x)
{
    Node* p = new Node;
    p->data = x;
    p->next = top;
    top = p;
}

char pop(Node*& top)
{
    char x = top->data;
    Node* p = top;
    top = top->next;
    delete p;
    return x;
}

int main()
{
    ifstream file("LOG.txt");

    string s;
    getline(file, s);

    Node* top = nullptr;

    for (char c : s)
    {
        if (c == ' ')
            continue;

        if (c == 't' || c == 'f' ||
            c == '(' || c == '!' ||
            c == '&' || c == '|')
        {
            push(top, c);
        }

        if (c == ')')
        {
            char b = pop(top);

            // ( ! t )
            if (top->data == '!')
            {
                pop(top); // !
                pop(top); // (

                if (b == 't')
                    push(top, 'f');
                else
                    push(top, 't');
            }
            else
            {
                char op = pop(top);
                char a = pop(top);
                pop(top); // (

                bool x = (a == 't');
                bool y = (b == 't');
                bool result;

                if (op == '&')
                    result = x && y;
                else
                    result = x || y;

                if (result)
                    push(top, 't');
                else
                    push(top, 'f');
            }
        }
    }

    cout << (top->data == 't');

    while (top != nullptr)
        pop(top);

    return 0;
}