Implement an array of stacks where stacks are defined :
typedef struct StackNode {
int data;
StackNode* next;
} StackNode;
Each array element points to a stack, each stack is initialized as an empty stack.
When you start adding elements it will start adding them to the stack in Stacks[0];
if you say -2
in stdin and then 4
for example, the next entries will go to Stacks[4];
For example:
5 10 -2 3 9 7 89 -1
will result in :
Stacks[0] -> 10 -> 5
Stacks[1]
Stacks[2]
Stacks[3] -> 89 -> 7 -> 9
-1
will stop the code from running.
I am having problem with implementing an array of stacks so any help would be appreciated :)