|
5鱼币
求求大佬帮我看看错在哪里
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define TRUE 1
#define OVERFLOW -2
#define FALSE 0
#define MAXSIZE 10
typedef struct Queue{
int *base; // 队列首地址
int front;
int rear;
}Queue,*LQueue;//这是我定义的队列结构体
typedef struct Node
{
int data;
struct Node* next;
}Node,*LNode;//节点的结构体
int InitQueue(LQueue Q){
Q->base=(int*)malloc(sizeof(int)*MAXSIZE);
Q->front = Q->rear = NULL;
return TRUE;
}
int Fullor(LQueue Q)
{
Q->front =Q->rear +1;
return(FALSE);
}
int InQueue(LQueue &Q,int &elem)
{
if ((Q->rear + 1) % MAXSIZE == (Q->front))
return FALSE;
Q->base[Q->rear] = elem;
Q->rear = (Q->rear + 1) % MAXSIZE;
return TRUE;
}
int OutQueue(LQueue &Q,int &elem)
{
if (Q->front == Q->rear)
return FALSE;
elem= Q->base[Q->front];
Q->front = (Q->front + 1) % MAXSIZE;
return TRUE;
}
int printQueue(LQueue Q)
{
printf("the queue is:\n");
for(int i =Q->front;i<=Q->rear;++i)
{
printf("%d",Q->base[i]);
}
return TRUE;
}
int main(void)
{
LQueue L;
InitQueue(L);
int i;
int elem;
int h;
printf("input is~:");
for(i=0;i<10;i++)
{
elem=i+25;
InQueue(L,elem);
return TRUE;
}
printQueue(L);
printf("请问你要舍弃多少个数字\n");
scanf("%d", &h);
while (h != 0)
{
OutQueue(L, elem);
h--;
}
printQueue(L);
return TRUE;
}
|
|