#include <iostream>

using namespace std;

class Automat{
    //Wektor stanu:
    public: bool m_state[2];
    //Wektor wejścia:
    public: bool m_input[2];
    //Wektor wyjścia:
    public: bool m_output[2];

    public: void inicjuj(){
        //Ustawienie stanu początkowego:
        m_state[0] = false;
        m_state[1] = false;
        //Ustawienie wejścia:
        m_input[0] = false;
        m_input[1] = false;
        //Początkowy stan wyjścia:
        funkcjaWyjscia();
    }

    public: void funkcjaPrzejscia(){
        m_state[0] = ((not (m_input[0]) and m_input[1]) or (not (m_state[1]) and m_state[0]));
        m_state[1] = ((not (m_state[1]) and (m_state[1] and m_input[1])) or (m_input[0] and m_input[1]));
    }

    public: void funkcjaWyjscia(){
        m_output[0] = m_state[0];
        m_output[1] = m_state[1];
    }
};

int main(){
    Automat automat;
    automat.inicjuj();
    //Stan początkowy 00 (1):
    cout << automat.m_output[0] << automat.m_output[1] << endl;
    //Przejście 00 (1) -> 01 (2):
    automat.m_input[0] = true;
    automat.m_input[1] = true;
    automat.funkcjaPrzejscia();
    automat.funkcjaWyjscia();
    cout << automat.m_output[0] << automat.m_output[1] << endl;
    //Przejście 01 (2) -> 00 (1):
    automat.m_input[0] = true;
    automat.m_input[1] = false;
    automat.funkcjaPrzejscia();
    automat.funkcjaWyjscia();
    cout << automat.m_output[0] << automat.m_output[1] << endl;
    //Przejście 00 (1) -> 01 (2):
    automat.m_input[0] = true;
    automat.m_input[1] = true;
    automat.funkcjaPrzejscia();
    automat.funkcjaWyjscia();
    cout << automat.m_output[0] << automat.m_output[1] << endl;
    //Przejście 01 (2) -> 10 (3):
    automat.m_input[0] = false;
    automat.m_input[1] = true;
    automat.funkcjaPrzejscia();
    automat.funkcjaWyjscia();
    cout << automat.m_output[0] << automat.m_output[1] << endl;
    //Przejście 10 (3) -> 01 (2):
    automat.m_input[0] = true;
    automat.m_input[1] = true;
    automat.funkcjaPrzejscia();
    automat.funkcjaPrzejscia(); //Przejście przez stan przejściowy (4) może wymagać podwójnego uruchomienia tej funkcji!
    automat.funkcjaWyjscia();
    cout << automat.m_output[0] << automat.m_output[1] << endl;
    //Przejście 01 (2) -> 00 (1):
    automat.m_input[0] = true;
    automat.m_input[1] = false;
    automat.funkcjaPrzejscia();
    automat.funkcjaWyjscia();
    cout << automat.m_output[0] << automat.m_output[1] << endl;
	return 0x00;
}
