#include "stdafx.h"

#include "stdio.h"
#include "stdlib.h"

typedef int DataType;

typedef struct Space
{
 DataType data;
 Space* next;
}Space;

typedef struct Queue
{
 Space* base;
 Space* top;
 int length;
 
}Queue;

Queue* initQ()
{
 Queue *myQ;
 myQ=(Queue *)malloc(sizeof(Queue));
 myQ->length;
 myQ->base=(Space *)malloc(sizeof(Space));
 myQ->base->next=NULL;
 myQ->top=myQ->base;
 return myQ;
}

void insQ(Queue* myQ, DataType data)
{
 Space *temp=(Space *)malloc(sizeof(Space));
 temp->next=NULL;
 temp->data=data;
 myQ->top->next=temp;
 myQ->top->next=myQ->top->next->next;
 myQ->length++;
}

void remQ(Queue* myQ)
{
 if(myQ->length==0)
  printf("the queue is empty");
 Space* temp=myQ->base->next;
 myQ->base->next=myQ->base->next->next;
 free(temp);
 myQ->length--;
}

void getTop(Queue* myQ)
{
 printf("%d  \n",myQ->base->next->data );
}

 

int main(int argc, char const *argv[])
{
 /* code */
 return 0;
}

相关文章:

  • 2021-08-21
  • 2021-12-08
  • 2021-09-25
  • 2021-09-26
  • 2021-07-17
猜你喜欢
  • 2021-07-29
  • 2021-06-04
  • 2021-12-25
  • 2022-02-05
  • 2021-11-26
  • 2021-11-29
  • 2021-12-22
相关资源
相似解决方案