#include "stdio.h"
#include "malloc.h"
int StrLen(const char*pData)
{
int i = 0;
if (pData == NULL)
{
return 0;
}
while (1)
{
if (*(pData + i) != 0)
{
++i;
}else
{
break;
}
}
return i;
}
char *StrCopy(char *pTo,const char *pFrom)
{
int i = 0;
if (pTo == NULL || pFrom == NULL)
{
return NULL;
}
while (1)
{
if ((*(pTo + i) = *(pFrom + i)) != 0)
{
++i;
}else
{
break;
}
}
return pTo;
}
int StrCmp(const char *pFirst,const char *pSecond)
{
int lenF,lenS,i,dis;
if (pFirst == NULL || pSecond == NULL)
{
return NULL;
}
lenF = StrLen(pFirst);
lenS = StrLen(pSecond);
if (lenF > lenS)
{
for (i = 0; i < lenS; ++i)
{
dis = *(pFirst + i) - *(pSecond + i);
if (dis != 0)
{
return dis;
}
}
return 1;
}else if (lenF < lenS)
{
for (i = 0; i < lenF; ++i)
{
dis = *(pFirst + i) - *(pSecond + i);
if (dis != 0)
{
return dis;
}
}
return -1;
}else
{
for (i = 0; i < lenF; ++i)
{
dis = *(pFirst + i) - *(pSecond + i);
if (dis != 0)
{
return dis;
}
}
return 0;
}
return 0;
}
typedef struct SibTreeNode
{
char data[50];
int valid;
int year;
int month;
int day;
int hour;
int minute;
int second;
int sonmulu;
int sonfile;
struct SibTreeNode * parent;
struct SibTreeNode *firstChild;
struct SibTreeNode *nextSibling;
}SibTreeNode;
typedef struct
{
SibTreeNode *root;
int size;
}SibTree;
typedef SibTreeNode *QueueDataType;
typedef struct
{
QueueDataType queue [50];
int front;
int rear;
int count; /* 队列的当前表长 */
} SeqCQueue;
//初始化
void QueueInitiate(SeqCQueue *Q)
{
Q->front=0;
Q->rear=0;
Q->count=0;
}
//判断队列非空
int QueueNotEmpty(SeqCQueue Q)
{
if(Q.count!=0) return 1;
else return 0;
}
//入队列
int QueueAppend(SeqCQueue *Q,QueueDataType x)
{
if(Q->count>0 && Q->rear==Q->front)
{
printf("队列已满无法插入!\n");
return 0;
}
else
{
Q->queue[Q->rear]=x;
Q->rear=(Q->rear+1)%50;
Q->count++;
return 1;
}
}
//出队列
int QueueDelete(SeqCQueue *Q,QueueDataType *x)
{
if(Q->count==0)
{
printf("队列已空无数据元素出队列!\n");
return 0;
}
else
{
*x=Q->queue[Q->front];
Q->front=(Q->front+1)%50;
Q->count--;
return 1;
}
}
//取对头数据元素
int QueueGet(SeqCQueue *Q,QueueDataType *x)
{
if(Q->count==0)
{
printf("队列已空无数据元素出队列!\n");
return 0;
}
else
{
*x=Q->queue[Q->front];
return 1;
}
}