当前位置:首页 > 数据结构(02331) > 正文内容

阅读下列算法,简述其功能。
1.voidDemol(SeqStack*S){
inti,arr[64],n=0;
while(!StackEmpty(S))arr[n++]=Pop(S);
for(i=0;i
2.SeqStackS1,S2,tmp;
DataTypeX;
…//假设栈tmp和S2已做过初始化
while(!StackEmpty(&S1))

高老师2年前 (2024-03-26)数据结构(02331)12

阅读下列算法,简述其功能。
1.voidDemol(SeqStack*S){
inti,arr[64],n=0;
while(!StackEmpty(S))arr[n++]=Pop(S);
for(i=0;i
2.SeqStackS1,S2,tmp;
DataTypeX;
…//假设栈tmp和S2已做过初始化
while(!StackEmpty(&S1))

X=Pop(&&S1);
Push(trap,x);
)
while(!StackEmpty(&tmp))
{
x=Pop(&tmp);
Push(g>S1,x);
Push(&>S2,x);
}
3.voidDemo2(SeqStack*S,intm)
{//设DataType为int型
SeqStackT;inti;
InitStack(&T);
while(!StackEmpty(S))
if((i=Pop(S))!=m)Push(&T,i);
while(!StackEmpty(&T))
{
i=Pop(&T);Push(S,i);
}

1.当栈不为空时,将栈中元素逆置。 2.复制栈S1到S2。 3.删除栈S中元素m。

扫描二维码免费使用微信小程序搜题/刷题/查看解析。

版权声明:本文由翰林刷题小程序授权发布,如需转载请注明出处。

本文链接:https://doc.20230611.cn/post/432074.html

分享给朋友: