91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

這是一個循環(huán)隊列的c語言實(shí)現(xiàn)程序,實(shí)現(xiàn)入隊、出隊等操作

資源截圖

代碼片段和文件信息

/***************************************************************
????這是一個循環(huán)隊列的c語言實(shí)現(xiàn)程序
????聲明:該程序僅作為學(xué)習(xí)參考,不得用于其他用途,否則后果自負(fù)!
????作者:jim船長(CSDN昵稱)
????個人主頁:https://me.csdn.net/luotuoxiansheng
????時間:2018/11/2
***************************************************************/
#include?
#include?

#define?MAXSIZE?10

typedef?int?ElemType;
typedef?int?Status;

typedef?struct
{
????ElemType?data[MAXSIZE];
????int?front;
????int?rear;
}Queue;

/*初始化隊列*/
Status?InitQueue(Queue?*Q)
{
????Q->front=0;
????Q->rear=0;
????return?1;
}

/*隊列長度*/
int?QueueLength(Queue?Q)
{
????return?(Q.rear-Q.front+MAXSIZE)%MAXSIZE;//計算隊列長度公式
}

/*入隊*/
Status?EnQueue(Queue?*QElemType?e)
{
????if((Q->rear+1)%MAXSIZE==Q->front)//判斷隊滿(即rear后移一位等于front)
????return?0;
????Q->data[Q->rear]=e;
????Q->rear=(Q->rear+1)%MAXSIZE;//rear后移一位
????return?1;
}

/*出隊*/
ElemType?DeQueue(Queue?*Q)
{
????ElemType?e;
????if(Q->front==Q->rear)//判斷隊空
????return?0;
????e=Q->data[Q->front];//隊首賦給e
????Q->front=(Q->front+1)%MAXSIZE;//front后移一位
????return?e;
}

int?main()
{
????int?chilength;
????Queue?Q;
????ElemType?e;
????InitQueue(&Q);
????while(1)
????????{
????????????printf(“\n1.入隊列???2.出隊列???3.查看當(dāng)前列?:“);
????????????scanf(“%d“&ch);
????????????switch(ch)
????????????{
????????????????case?1:
????????????????????????{
????????????????????????????printf(“插入數(shù)字:“);
????????????????????????????scanf(“%d“&e);
????????????????????????????if(?EnQueue(&Qe))
????????????????????????????printf(“Success!\n“);
????????????????????????????else
?????????????????????????????????printf(“Faild!\n“);
????????????????????????}break;
????????????????case?2:
????????????????????????{
????????????????????????????printf(“The?out-queue?number?is:%d\n“DeQueue(&Q));
????????????????????????}break;
????????????????case?3:
????????????????????????{
????????????????????????????length=QueueLength(Q);
????????????????????????????for(i=0;i????????????????????????????{
????????????????????????????????printf(“%d\n“Q.data[Q.front+i]);
????????????????????????????}
????????????????????????????printf(“Length?is:?%d\n“l(fā)ength);
????????????????????????}break;
????????????????default:printf(“error!\n“);
????????????}
????????}


}

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-11-02?16:23??循環(huán)隊列\(zhòng)
?????文件????????2562??2018-11-02?16:44??循環(huán)隊列\(zhòng)SqQueue.c
?????文件???????28887??2018-11-02?16:21??循環(huán)隊列\(zhòng)SqQueue.exe
?????文件????????1736??2018-11-02?16:21??循環(huán)隊列\(zhòng)SqQueue.o

評論

共有 條評論

相關(guān)資源