第一范文网 - 专业文章范例文档资料分享平台

华南农业大学数据结构上机答案实验

来源:用户分享 时间:2025/7/28 19:18:24 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

// 从栈顶到栈底依次输出栈中的每个元素

SElemType *p = (SElemType *)malloc(sizeof(SElemType)); p = S.top ; //请填空

if(S.top==S.base)printf("The Stack is Empty!"); //请填空 else {

printf("The Stack is: "); p--;

while(p>=S.base) //请填空 {

printf("%d ", *p); p-- ; //请填空 } }

printf("\\n"); return OK; } int main() { int a; SqStack S;

SElemType x, e;

if(InitStack(S)) // 判断顺序表是否创建成功,请填空 {

printf("A Stack Has Created.\\n"); } while(1) {

printf("1:Push \\n2:Pop \\n3:Get the Top \\n4:Return the Length of the Stack\\n5:Load the Stack\\n0:Exit\\nPlease choose:\\n"); scanf("%d",&a); switch(a) {

case 1: scanf("%d", &x);

if(!Push(S,x)) printf("Push Error!\\n"); // 判断Push是否合法,请填空

else printf("The El

ement %d is Successfully Pushed!\\n", x); break;

case 2: if(!Pop(S,e)) printf("Pop Error!\\n"); // 判断Pop是否合法,

请填空

else printf("The Element %d is Successfully Poped!\\n", e); break;

case 3: if(!GetTop(S,e))printf("Get Top Error!\\n"); // 判断Get Top是否合法,请填空

else printf("The Top Element is %d!\\n", e); break;

case 4: printf("The Length of the Stack is %d!\\n",StackLength(S)); //请填空 break;

case 5: StackTraverse(S); //请填空 break;

case 0: return 1; } } }

8584 循环队列的基本操作

时间限制:1000MS 内存限制:1000K 提交次数:366 通过次数:157

题型: 编程题 语言: 无限制

Description

创建一个空的循环队列,并实现入队、出队、返回队列的长度、返回队头元素、队列的遍历等基本算法。请将下面的程序补充完整。

#include<malloc.h> #include<stdio.h> #define OK 1 #define ERROR 0

typedef int Status; // Status是函数的类型,其值是函数结果状态代码,如OK等

typedef int QElemType;

#define MAXQSIZE 100 // 最大队列长度(对于循环队列,最大队列长度要减1)

搜索更多关于: 华南农业大学数据结构上机答案实验 的文档
华南农业大学数据结构上机答案实验.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c7wb25944gf7yqpo85se79mzf00wrvr00is6_2.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top