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

发布时间 : 星期五 文章华南农业大学数据结构上机答案实验更新完毕开始阅读ca66fde9988fcc22bcd126fff705cc1755275f16

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

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)