//////////////////////////////////////////////////////////
// 文件:config.h
//////////////////////////////////////////////////////////
#ifndef __CONFIG_H
#define __CONFIG_H
//这一段无需改动
//This segmentshould not be modified
#ifndef TRUE
#define TRUE 1
#endif
#define __CONFIG_H
//这一段无需改动
//This segmentshould not be modified
#ifndef TRUE
#define TRUE
#endif
#ifndef FALSE
#define FALSE 0
#endif
#define FALSE 0
#endif
typedef unsigned char uint8;
typedef signed char int8;
typedef unsigned short uint16;
typedef signed short int16;
typedef unsigned int uint32;
typedef signed int int32;
typedef float fp32;
typedef signed
typedef unsigned short uint16;
typedef signed
typedef unsigned int
typedef signed
typedef float
#i nclude “FIFOQUEUE.h”
#endif
//////////////////////////////////////////////////////////
// 文件:FIFOQUEUE.h
//////////////////////////////////////////////////////////
#ifndef _FIFOQUEUE_H
#define _FIFOQUEUE_H
#define _FIFOQUEUE_H
#define ElemType uint8
#define QueueSize 20 //fifo行列的巨细
#define QueueFull 0 //fifo满置0
#define QueueEmpty 1 //FIFO空置1
#define QueueOperateOk 2 //行列操作完结 赋值为2
#define QueueFull
#define QueueEmpty
#define QueueOperateOk 2
struct FifoQueue
{
uint16 front; //行列头
uint16 rear; //行列尾
uint16 count; //行列计数
ElemType dat[QueueSize];
};
{
};
//Queue Initalize
extern void QueueInit(struct FifoQueue *Queue);
extern void QueueInit(struct FifoQueue *Queue);
// Queue In
extern uint8 QueueIn(struct FifoQueue *Queue,ElemType sdat);
extern uint8 QueueIn(struct FifoQueue *Queue,ElemType sdat);
// Queue Out
extern uint8 QueueOut(struct FifoQueue *Queue,ElemType *sdat);
extern uint8 QueueOut(struct FifoQueue *Queue,ElemType *sdat);
#endif
//////////////////////////////////////////////////////////
// 文件:FIFOQUEUE.C
//////////////////////////////////////////////////////////
#i nclude “config.h”
//Queue Init
void QueueInit(struct FifoQueue *Queue)
{
Queue->front = Queue->rear;//初始化时行列头行列首相连
Queue->count = 0; //行列计数为0
}
void QueueInit(struct FifoQueue *Queue)
{
}
// Queue In
uint8 QueueIn(struct FifoQueue *Queue,ElemType sdat) //数据进入行列
{
if((Queue->front == Queue->rear) && (Queue->count == QueueSize))
{ // full //判别假如行列满了
return QueueFull; //回来行列满的标志
}else
{ // in
Queue->dat[Queue->rear] = sdat;
Queue->rear = (Queue->rear + 1) % QueueSize;
Queue->count = Queue->count + 1;
return QueueOperateOk;
}
}
uint8 QueueIn(struct FifoQueue *Queue,ElemType sdat) //数据进入行列
{
}
// Queue Out
uint8 QueueOut(struct FifoQueue *Queue,ElemType *sdat)
{
if((Queue->front == Queue->rear) && (Queue->count == 0))
{ // empty
return QueueEmpty;
}else
{ // out
*sdat = Queue->dat[Queue->front];
Queue->front = (Queue->front + 1) % QueueSize;
Queue->count = Queue->count – 1;
return QueueOperateOk;
}
}
uint8 QueueOut(struct FifoQueue *Queue,ElemType *sdat)
{
}
//////////////////////////////////////////////////////////
// 文件:Main.C
//////////////////////////////////////////////////////////
#i nclude
#i nclude “config.h”
#i nclude “config.h”
void main(void)
{
struct FifoQueue MyQueue;
ElemType sh;
uint8 i;
{
}
行列是一种先进先出(first infirst out,缩写为FIFO)的线性表。它只答应在标的一端进行刺进,而在另一端删去元素。这和咱们日常日子中的排队是共同的,最早进入行列的元素最早脱离。在行列中,答应刺进的一端叫做队尾(rear),答应删去的一端则称为仇人(front)(排队买票,窗口一端叫仇人,结尾进队叫队尾)。