云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > 数据结构_实验三_栈和队列及其应用

数据结构_实验三_栈和队列及其应用

  • 62 次阅读
  • 3 次下载
  • 2025/6/21 16:02:51

}

if(L->next==NULL) return ERROR; e=L->next->data; return OK;

Status StackEmpty(Lq_Stack L){ }

int StackLength(Lq_Stack L){ }

Status DestroyStack(Lq_Stack &L){ }

void Menu(Lq_Stack &L,SElemType e){

//输出菜单选择执行得功能 int select=1; while(select) {

cout<<\————————————\//销毁栈 LqStack *p; while(!L) { } return OK;

L=p; L=L->next; free(p); //计算栈得长度 return L->data; //判断栈就是否为空

if(L->next==NULL){return ERROR;} else return OK;

cout<<\请选择功能\

cout<<\——————1、入栈\cout<<\——————2、出栈\cout<<\——————3、得到顶部数据\cout<<\——————4、判断栈就是否为空\cout<<\——————5、输出栈得长度\cout<<\——————0、退出程序\cout<<\您得选择就是:\cin>>select; switch (select){ case 0:break; case 1:

cout<<\cin>>e; if(push(L,e)){ }

else cout<<\break;

cout<<\

case 2:

if(pop(L,e)){

cout<<\

else cout<<\break;

case 3:

if(GetTop(L,e)){

cout<<\

else cout<<\break;

case 4:

}

}

if(StackEmpty(L)){

cout<<\

else cout<<\break;

case 5: }

cout<<\break;

//Lstack、h

#include #include using namespace std; const int OK=1; const int ERROR=0; typedef int SElemType; typedef int Status; typedef struct LqStack{

SElemType data; struct LqStack *next;

}LqStack,*Lq_Stack;

Status InintStack (Lq_Stack &L);//创建栈 Status push (Lq_Stack &L,SElemType e);//入栈 Status pop (Lq_Stack &L,SElemType &e);//出栈

Status GetTop(Lq_Stack L, SElemType &e);//得到栈顶数据 Status StackEmpty(Lq_Stack L);//判断栈就是否为空 int StackLength(Lq_Stack L);//计算栈得长度 Status DestroyStack(Lq_Stack &L);//销毁栈

void Menu(Lq_Stack &L,SElemType e);//输出菜单选择执行得功能

? 运行结果:

(2)

应用栈得基本操作,实现数制转换(任意进制);;

? 代码部分: //Main、cpp

#include\、h\int main(){ }

int number;

cout<<\要将数值转换为多少进制 \cin>>number; conversion(number); return 0;

SStack、cpp

#include\、h\Status InitStack(SStack &S){

//创建栈

S、dase=(ElemType *)malloc(STACK_INIT_SIZE * sizeof(ElemType)); if (!S、dase) exit(ERROR);

搜索更多关于: 数据结构_实验三_栈和队列及其应用 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

} if(L->next==NULL) return ERROR; e=L->next->data; return OK; Status StackEmpty(Lq_Stack L){ } int StackLength(Lq_Stack L){ } Status DestroyStack(Lq_Stack &L){ } void Menu(Lq_Stack &L,SElemType e){ //输出菜单选择执行得功能 int select=1; while(select) { cout<<\————————————\//销毁栈 LqStack *p; while(!L) { } return OK; L=p; L=L->

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com