注意:此页面搜索的是所有试题
题目内容
(国家开放大学数据结构复习题)
在下面空格处填写适当的语句,以使下面的循环队列的入队和出队算法完整。
define MAXSIZE 100;
typedef char Elemtype;
typedef struct
{
Elemtype queue [MAXSIZE];
int front,rear;
}sequeuetype;
Sequeuetype Q;
int encqueue(sequeuetype*Q,elemtype x)
if ((Q->rear+1)%MAXSIZE==Q->front)
printf(“队列已满!\n”);
return 1;
else
Q->rear=(Q->rear+1)%MAXSIZE;
(1)
return 0;
} /*入队算法*/
Elemtype del_cqueue(sequeuetype *Q)
if ( (2) )
printf(“队列为空!\n”);
return 1;
else
Q->front=(Q->front+1)%MAXSIZE;
return(Q-queue[Q->front]);
/*出队算法*/
A.(1) (Q->rear+1)%MAXSIZE==Q->front (2) Q->front=(Q->front+1)%MAXSIZE;
B.(1) (Q->front+1)%MAXSIZE==Q->rear (2) Q->rear=(Q->rear+1)%MAXSIZE;
C.(1) Q->front==Q->rear (2) Q->queue[Q->rear]=x;
D.(1) Q->queue[Q->rear]=x; (2) Q->front==Q->rear
define MAXSIZE 100;
typedef char Elemtype;
typedef struct
{
Elemtype queue [MAXSIZE];
int front,rear;
}sequeuetype;
Sequeuetype Q;
int encqueue(sequeuetype*Q,elemtype x)
if ((Q->rear+1)%MAXSIZE==Q->front)
printf(“队列已满!\n”);
return 1;
else
Q->rear=(Q->rear+1)%MAXSIZE;
(1)
return 0;
} /*入队算法*/
Elemtype del_cqueue(sequeuetype *Q)
if ( (2) )
printf(“队列为空!\n”);
return 1;
else
Q->front=(Q->front+1)%MAXSIZE;
return(Q-queue[Q->front]);
/*出队算法*/
A.(1) (Q->rear+1)%MAXSIZE==Q->front (2) Q->front=(Q->front+1)%MAXSIZE;
B.(1) (Q->front+1)%MAXSIZE==Q->rear (2) Q->rear=(Q->rear+1)%MAXSIZE;
C.(1) Q->front==Q->rear (2) Q->queue[Q->rear]=x;
D.(1) Q->queue[Q->rear]=x; (2) Q->front==Q->rear
参考答案