#include "stdio.h" #define maxsize 50 typedef int elemtype;
typedef struct {elemtype data[maxsize]; int front,rear; } queue; elemtype e;
/***********************************************/ void init_queue(queue *h) {h->front=h->rear=0; } /********************************************/ int empty_queue(queue h) {return h.front==h.rear;} /********************************************/ int full_queue(queue h) {return (h.rear+1)%maxsize==h.front;} /********************************************/ void append_queue(queue *p) {int i,n,line; clrscr(); line=10; gotoxy(20,line); printf("How many numbers which you will append ?"); scanf("%d",&n); i=0; while(i<n) { if(full_queue(*p)) {clrscr(); gotoxy(16,11); printf("Sorry ! The queue is full ! Cann't append it!"); break; } else { line=line+2; if(line>24) {clrscr();line=2;} gotoxy(20,line); printf("Please input NO.%d number:",i+1); scanf("%d",&e); p->rear=(p->rear+1)%maxsize; p->data[p->rear]=e; } i++; } getch(); } /*****************************************************/ void output(queue h) {int i,num=0; clrscr(); gotoxy(20,10); if(empty_queue(h)) printf("Sorry ! The queue is emtpy ! "); else {printf(" "); for(i=h.front;i!=h.rear;) {i=(i+1)%maxsize; printf("%5d",h.data[i]);num++; if(num%10==0)printf(" "); } } gotoxy(20,22); printf("Press Any key to Return ."); getch(); } /********************************************/ void delete_queue(queue *h) { clrscr(); gotoxy(20,11); if(empty_queue(*h)) printf("Sorry ! The queue is emtpy ! "); else { e=h->data[h->front+1]; h->front=(h->front+1)%maxsize; printf("The element that came out is %d. ",e); } getch(); } /********************************************/ void getelem(queue h,elemtype *p) { clrscr(); gotoxy(20,11); if(empty_queue(h)) printf("Sorry ! The queue is emtpy ! "); else { *p=h.data[h.front+1]; printf("The elemment which you get is %d.",*p); } getch(); } /********************************************/ void quit() { clrscr(); gotoxy(20,12); printf("e use it again ! "); getch(); exit(0); } /********************************************/ void main() { int n; queue qe; init_queue(&qe);
while(1) {clrscr(); gotoxy(20,7); printf(" ===== menu ===== "); gotoxy(20,9); printf("******************************** "); gotoxy(20,10);printf("* 1. append 2. deleted * "); gotoxy(20,11);printf("* 3. getelem 4. output * "); gotoxy(20,12);printf("* 0. quit * "); gotoxy(20,13);printf("******************************** "); gotoxy(20,16); printf("Please input your choice : "); scanf("%d",&n); while(n<0||n>4) {printf(" Input Error ! Please input again ! "); scanf("%d",&n); } switch(n) {case 1:append_queue(&qe); break; case 2:delete_queue(&qe); break; case 3:getelem(qe,&e); break; case 4:output(qe); break; case 0:quit(); } } }
virmach怎么样?virmach家这几年非常火,从商家的黑五闪购开始,以超低的价格吸引了大批的国人客户,而且商家的机器还是非常稳定的,站长手里的4.75刀年付已经用了两年了,非常稳定,不过商家到国内的线路一般,目前商家新上了夏季优惠促销,价格低到发指,年付7.2美元起,商家反馈将在9月开始更换AMD+NVMe平台,这个消息从年初就有了,不过一直没有更换,目前这个时间也不确定是否准确。点击进入:...
spinservers是一家主营国外服务器租用和Hybrid Dedicated等产品的商家,Majestic Hosting Solutions LLC旗下站点,商家数据中心包括美国达拉斯和圣何塞机房,机器一般10Gbps端口带宽,且硬件配置较高。目前,主机商针对达拉斯机房机器提供优惠码,最低款Dual E5-2630L v2+64G+1.6TB SSD月付89美元起,支持PayPal、支付宝等...
青果网络怎么样?青果网络隶属于泉州市青果网络科技有限公司,青果网络商家成立于2015年4月1日,拥有工信部颁发的全网IDC/ISP/IP-VPN资质,是国内为数不多具有IDC/ISP双资质的综合型云计算服务商。青果网络是APNIC和CNNIC地址分配联盟成员,泉州市互联网协会会员单位,信誉非常有保障。目前,青果网络商家正式开启了618云特惠活动,针对国内外机房都有相应的优惠。点击进入:青果网络官方...