問(wèn)答題
【EX-3-7】下面算法的功能是:利用順序棧的基本運(yùn)算返回指定棧中的棧底元素,要求仍保持棧中元素不變。說(shuō)明:順序棧的基本操作可以直接調(diào)用。請(qǐng)?jiān)诳瞻滋幪钊胝_的語(yǔ)句。 bool GetBottom(SqStack st, ElemType &x) { ElemType e; SqStack tmpst; ________①_________; if (StackEmpty(st)) return 0; while (_______②_______) { Pop(st, x); _______③________; } while (_________④__________) { Pop(tmpst, e); _______⑤_________; } return 1; }
答案:
① `InitStack(tmpst);` 初始化一個(gè)臨時(shí)棧 tmpst,用于暫存原棧 st 中的元素。 ② `!St...