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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!