Question: Write the function odds which takes in a stack by reference and changes it to only contain the odd elements. That is, if the stack
Write the function odds which takes in a stack by reference and changes it to only contain the odd elements. That is, if the stack initially contains 3, 6, 1, 7, 8 then after calling odds, the stack will contain 3, 1, 7. Note that the order of the elements in the stack remains the same. Hint: you may want an additional queue or stack! Assume all libraries needed for your implementation have already been included.
void odds(stack &s) {
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
