栈操作之双端顺序栈

数据结构:

栈是允许在同一端进行插入和删除操作的特殊线性表。允许进行插入和删除操作的一端称为栈顶(top),另一端为栈底(bottom);栈底固定,而栈顶浮动;栈中元素个数为零时称为空栈。插入一般称为进栈(PUSH),删除则称为退栈(POP)。栈也称为后进先出表。

操作系统:

由编译器自动分配释放 ,存放函数的参数值,局部变量的值等。其操作方式类似于数据结构中的栈

栈使用的是一级缓存, 他们通常都是被调用时处于存储空间中,调用完毕立即释放。

双端栈模板代码:

#define TRUE 1
#define FALSE 0
#define M 100

typedef struct
{
StackElementType Stack[M];
StackElementType top[2]; /*top[0]和top[1]分别为两个栈顶指示器*/
}DqStack;

/*初始化操作。*/
void InitStack(DqStack *S)
{
S->top[0]=-1;
S->top[1]=M;
}

/*进栈操作。*/
int Push(DqStack *S,StackElementType x,int i)
{
/*把数据元素x压入i号堆栈*/
if(S->top[0]+1==S->top[1]) /*栈已满*/
return(FALSE);
switch(i)
{
case 0:
S->top[0]++;
S->Stack[S->top[0]]=x;
break;
case 1:
S->top[1]–;
S->Stack[S->top[1]]=x;
break;
default: /*参数错误*/
return(FALSE)
}
return(TRUE);
}

/*出栈操作。*/
int Pop(DqStack *S,StackElementType *x,int i)
{
/* 从i 号堆栈中弹出栈顶元素并送到x中 */
switch(i)
{
case 0:
if(S->top[0]==-1)
return(FALSE);
*x=S->Stack[S->top[0]];
S->top[0]–;
break;
case 1:
if(S->top[1]==M)
return(FALSE);
*x=S->Stack[S->top[1]];
S->top[1]++;
break;
default:
return(FALSE);
}
return(TRUE);
}

波比源码 – 精品源码模版分享 | www.bobi11.com
1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长!
2. 分享目的仅供大家学习和交流,您必须在下载后24小时内删除!
3. 不得使用于非法商业用途,不得违反国家法律。否则后果自负!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
5. 如有链接无法下载、失效或广告,请联系管理员处理!
6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需!
7. 本站源码并不保证全部能正常使用,仅供有技术基础的人学习研究,请谨慎下载
8. 如遇到加密压缩包,请使用WINRAR解压,如遇到无法解压的请联系管理员!

波比源码 » 栈操作之双端顺序栈

124 评论

  1. buy buspar 5mg online cheap buy buspar sale ditropan online order

  2. order benicar 10mg generic cheap calan diamox 250 mg price

  3. online roulette for real money blackjack game play great poker online

  4. buy doxycycline 100mg without prescription buy doxycycline pills buy cleocin 300mg without prescription

  5. diamox 250mg ca oral imuran order generic imuran 25mg

  6. order pepcid online generic pepcid mirtazapine 30mg generic

  7. tadalafil price clopidogrel ca amoxicillin 250mg price

  8. oral azathioprine 25mg imuran us buy naproxen pill

  9. phenergan drug cialis daily cialis 40mg canada

  10. buy tadalafil 10mg online tadalafil dosage medication for ed dysfunction

  11. purchase imitrex generic cost imitrex dutasteride pill

  12. accutane 10mg without prescription amoxil price where can i buy azithromycin

  13. buy cheap generic levitra buy zanaflex pill buy plaquenil medication

  14. buy ramipril 10mg pills amaryl tablet buy generic arcoxia 60mg

  15. asacol uk cost astelin 10ml buy irbesartan 150mg without prescription

  16. order temovate generic buy buspar cheap buy amiodarone 100mg pill

  17. buy trimethoprim without prescription brand cleocin buy cleocin sale

  18. buy dutasteride pill avodart oral order mobic 7.5mg pills

  19. celecoxib 100mg for sale order flomax ondansetron 8mg sale

  20. buy pills for erectile dysfunction tadalafil women order tadalafil 10mg without prescription

  21. buy hytrin without prescription oral terazosin 1mg buy generic cialis 10mg

  22. order tacrolimus 1mg without prescription buy requip cheap buy requip 1mg pill

评论已关闭

Hi, 如果你对这款模板有疑问,可以跟我联系哦!

联系站长
赞助VIP 享更多特权,建议使用 QQ 登录
喜欢我嘛?喜欢就按“ctrl+D”收藏我吧!♡