题目内容

链栈的出栈操作int *pop_linkstack(linkstack *s,elementtype y){linkstack *p;if((1)){printf(“溢出\n”);return 0;}else{p=s;y=s->data;s= (2);free(p);return 1;}}

查看答案
更多问题

循环队列的出队操作elementtype delete_cyqueue(Cqueue *cp,elementtype y){if((1)){printf(“溢出\n”);return NULL;}else{y=cp->element[cp->front];cp->front=(2);return y;}}

写出下列程序段的输出结果:栈结构定义为typedef struct astack *Stack;typedef struct astack{int top; //栈顶位置int maxtop; //栈顶位置的最大值StackItem *data; //栈元素数组指针}Astack;基本函数包括(1)初始化栈 StackInit (Stack S)(2)判断栈是否为空 int StackEmpty(Stack S)(3)判断栈是否满 int StackFull(Stack S)(4)入栈 Push(StackItem x,Stack S)(5)出栈 StackItem Pop(Stack S)(6)获取栈顶元素内容 StackItem StackTop(Stack S)void main( ) {Stack S;char x, y;x = 'c';y = 'k';Push ( x );Push ( 'a' );Push ( y );x=Pop ( S );Push ( 't' );Push ( x );x=Pop ( S );Push ( 's' );while (!StackEmpty ( ) ){y= Pop (S );printf(“%c”, y);}printf(“%c\n”, x);}输出结果:______________________

写出下列程序段的输出结果:队列结构定义为typedef struct qnode *qlink;struct qnode{QItem element;qlink next;}Qnode; //队列结点定义typedef struct lque *Queue;typedef struct lque{qlink front; //队首结点指针qlink rear; //队尾结点指针}Lqueue;基本函数为(1)初始化队列 Queue QueueInit()(2)入队 void EnterQueue(QItem x,Queue Q)(3)出队 QItem DeleteQueue(Queue Q)(4)获取队头元素内容 QItem QueueFirst(Queue Q)(5)判断队列是否为空 int QueueEmpty(Queue Q)void main( ){Queue Q;char x = 'e', y = 'c';EnterQueue ( 'h' , Q);EnterQueue ( 'r' , Q);EnterQueue ( y , Q);x= DeleteQueue (Q);EnterQueue ( x, Q );x=DeleteQueue ( Q);EnterQueue ( 'a', Q );while (!QueueEmpty ( ) ){y= DeleteQueue ( Q );printf(“%c”, y);}printf(“%c\n”, x);}输出结果:______________________

简述下述算法功能void unknown ( Queue &Q ){Stack S;int d;while (!QueueEmpty (Q ) ){d= DeleteQueue (Q);Push ( d , S);}while (!Stack Empty (S ) ){d= Pop ( S );EnterQueue ( d, Q );}}功能是:_________________________________________

答案查题题库