⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 描述了队列的基本操作 它的存储结构采取的顺序形式
💻 C
字号:
/*
********************************************************************
*函数名称:          主函数
*
*函数描述:          建立一个循环顺序队列 满足单片机中的需要
*
*修改时间:          08-09-22
********************************************************************
*/

#include <stdlib.h>
#include <stdio.h>
#include "userconst.h"
#include "queue.h"

void main(void)
{
	unsigned int state = 3;                       /* state是char型 比较的时候和相应的整型不同 */
	unsigned int element;                         /* 写成为char 回车号都会被记录 */
	unsigned char i = 0;
	extern unsigned char QueueFlg;

	Sequeue *head;

	head = (Sequeue *)malloc(sizeof(Sequeue));

	Init_Queue(head);

	while(1)
	{
		printf("请输入命令字符\n");
	    printf("0-输入队列中元素;1-删除队列中头元素;2-显示队列状态\n其中队列最大元素数目为: %d\n", QueueNum);
	
		scanf("%d", &state); 
		switch(state)
		{
			case 0: 
				   printf("请您输入队列中元素\n");
				   
				   scanf("%u", &element);
				   En_Queue(head, element);

				   break;

			case 1:
				   printf("删除的元素为: %d\n", De_Queue(head));
				   break;

			case 2:
				   printf("此时队列为: ");
				   Print_Queue(head);
				   break;

				   
			default: 
				   printf("输入命令无效,请重新输入\n");
				   break;
		}
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -