I'm trying to write a logic gates circuit simulator and everything is working so far except for one thing. My structure looks like this:
struct node
{
int number;
bool has_value;
bool is_input;
bool value;
Gate operation;
node* input1;
node* input2;
};
The program calculates output value by using recursion, so any kind of loop inside the structure messes everything up. My question is: How do I detect something like this (see picture) , cause i can't come up with anything that works.