Suppose I have something along the lines:
#include <iostream>
#include <cstdlib>
#include <vector>
using namespace std;
const int MAX_EDGES = 4;
...
int main() {
...
int edges[4];
cout << "Enter the outward-edges for node " << i+1 << ":" << endl;
cin >> edges[0] >> edges[1] >> edges[2] >> edges[3];
...
}
However, I'm in a situation where each node (which is defined as a struct somewhere above) may not have 4 "outward-edges". Therefore I would like the user to only have to input those edges to which this node is connected and not have to enter -1 or some such to represent no outward edges. For example, right now we might have the input
2
3
-1
-1
To represent that node i+1 (we're inside a for loop at the moment) has two outward edges, namely to node 2 and 3.
However I would like to be able to make this just 2 3
.
Any help appreciated! Cheers.