数据结构课程实验报告学生姓名王稼骏学号1815001209149班级指导老师实验名称栈、队列、递归程序设计实验成绩实验报告实验概述实验目的:编写一个算法,输出指定栈中的栈底元素,并使得原栈中的元素倒置。实验要求:(1)正确理解栈的先进后出的操作特点,建立初始栈,通过相关操作显示栈底元素。(2)程序中要体现出建栈过程和取出栈底元素后恢复栈的入栈过程,按堆栈的操作规则打印结果栈中的元素。实验基本原理:(1)采用顺序栈,即用数组存储栈元素。(2)设定一个临时队列,用来存放从初始栈中出栈的元素。(3)取出栈底元素后,将队列中的元素逐一出队并压入初始栈中。实验内容实验设计思路、步骤和方法等:(1)根据栈的先进后出特点,来进行实验(2)建立顺序栈、临时队列、依次取出压入栈实验过程(实验中涉及的记录、数据、分析):#include#include#defineMaxSize100typedefintElemType;typedefstruct{ElemTypedata[MaxSize];inttop;}SeqStack;typedefstruct{ElemTypedata[MaxSize];intfront,rear;}SeqQueue;voidInitStack(SeqStack*s);intStackEmpty(SeqStack*s);intStackFull(SeqStack*s);voidPush(SeqStack*s,ElemTypex);ElemTypePop(SeqStack*s);ElemTypeGetTop(SeqStack*s);voidDispStack(SeqStack*s);voidDispBottom(SeqStack*s);voidInitQueue(SeqQueue*sq);intQueueEmpty(SeqQueue*sq);voidInQueue(SeqQueue*sq,ElemTypex);ElemTypeOutQueue(SeqQueue*sq,ElemTypex);ElemTypeGetQueue(SeqQueue*sq)voidmain(){SeqStack*s;SeqQueue*sq;ElemTypex;intn,i;printf("(1)初始化栈s\n");s=(SeqStack*)malloc(sizeof(SeqStack));InitStack(s);printf("(2)栈为%s\n",(StackEmpty(s)?"空":"非空"));printf("(3)输入要进栈的数据个数:");scanf("%d",&n);printf("依次输入进栈的%d个整数:",n);for(i=0;itop=-1;}intStackEmpty(SeqStack*s){if(s->top==-1)return1;elsereturn0;/*否则返回0*/}intStackFull(SeqStack*s){if(s->top==MaxSize-1)return1;elsereturn0;}voidPush(SeqStack*s,ElemTypex){if(StackFull(s)){printf("栈满溢出错误!\n");exit(1);}s->top++;s->data[s->top]=x;}ElemTypePop(SeqStack*s){if(StackEmpty(s)){printf("栈下溢错误!\n");exit(1);}s->top--;returns->data[s->top+1];}ElemTypeGetTop(SeqStack*s){if(StackEmpty(s)){printf("栈下溢错误!\n");exit(1);}returns->data[s->top];}voidDispStack(SeqStack*s){inti;for(i=s->top;i>=0;i--)printf("%d",s->data[i]);printf("\n");}voidDispBottom(SeqStack*s){printf("%d",s->data[0]);printf("\n");}voidInitQueue(SeqQueue*sq){sq->front=sq->rear=0;}intQueueEmpty(SeqQueue*sq){if(sq->rear==sq->front)return1;elsereturn0;}voidInQueue(SeqQueue*sq,ElemTypex){if((sq->rear+1)%MaxSize==sq->front){printf("循环队列已满!\n");exit(1);}sq->data[sq->rear]=x;sq->rear=(sq->rear+1)%MaxSize;}ElemTypeOutQueue(SeqQueue*sq,...