C++
Using the Stack operations, write a pseudocode routine, dupA, that
takes aStack for string, checks to see if the top starts with ‘A’
or ‘a’. If so, duplicate the top of the stack (i.e. pop a
copy of that value onto the stack) else if length > 10,
pop it off the stack
Dear student, I have written both pseudocode and code. Please go through them and let me know if you have any doubts.
Pseudocode :
Code :
void dubA(stack<string> stk){
if(stk.empty()==true)
return ;
else{
tempString = stk.top();
if(tempString[0] == 'A' || tempString[0] =='a'){
stk.push(tempString);
}else if(tempString.length()>10){
stk.pop();
}
}
}
Hope you got your answer ;)
If you still have any doubts please let me know in the comment box. Thanks! happy learning ;)
Get Answers For Free
Most questions answered within 1 hours.