c语言实现链式队列

#include"stdio.h"
#include"stdlib.h"
#include"stdbool.h"
typedef int status;
typedef struct
{
 int money;
 struct queue* next;
}queue;
typedef struct
{
 queue* front;
 queue* rear;
}linkqueue;
void initqueue(queue* p,linkqueue* q)
{
 p = (queue*)malloc(sizeof(queue));
 q->front = p;
 q->rear = p;
}
void destoryqueue(queue* p)
{
 do
 {
  queue* pi;
  pi = p;
  free(p);
  queue* p = pi->next;
 } while (p->next = NULL);
}
void clearqueue(queue* p)
{
 do
 {
  p->money = NULL;
  p = p->next;
 }while(p->next = NULL);
}
bool queueempty(queue* p)
{
 for (;;)
 {
  while (p->money == 0)
  {
   p = p->next;
   if (p->next == 0)
    return 1;
  }
  if (p->next != 0)
   return 0;
 }
}
status queuelength(queue * p)
{
 int a = 0;
 do
 {
  if (p->money == 0)
   a++;
  p = p->next;
 } while (p->next == NULL);
 return a;
}
status gethead(queue* p)
{
 if (queuelength(p) == 0)
  return 0;
 else
  return p->money;
}
void enqueue(int q, queue* p)
{
 queue* pi;
 pi = (queue*)malloc(sizeof(queue));
 pi->money = q;
 pi->next = NULL;
 p->next = pi;
}
char dequeue(int* a, queue* p)
{
 if (queuelenth(p) != )
 {
  a = p->money;
  return 1;
 }
 else
  return 0;
}
int add(int a, int b)
{
 return a + b;
}
void visit(queue* p, int(*add)(int a, int b))
{
 do
 {
  p->money = (p->money, p->money);
  p = p->next;
 } while (p->next == NULL);
}

你可能感兴趣的:(c语言实现链式队列)