#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(); } } }
spinservers是一家主营国外服务器租用和Hybrid Dedicated等产品的商家,Majestic Hosting Solutions LLC旗下站点,商家数据中心包括美国达拉斯和圣何塞机房,机器一般10Gbps端口带宽,且硬件配置较高。目前,主机商针对达拉斯机房机器提供优惠码,最低款Dual E5-2630L v2+64G+1.6TB SSD月付89美元起,支持PayPal、支付宝等...
LOCVPS商家我们还是比较熟悉的老牌的国内服务商,包括他们还有其他的产品品牌。这不看到商家的信息,有新增KVM架构轻量/迷你套餐,提供的机房包括香港云地和美国洛杉矶,适用全场8折优惠,月付29.6元起。LOCVPS是一家成立于2011年的稳定老牌国人商家,主要从事XEN、KVM架构的国外VPS销售,主推洛杉矶MC、洛杉矶C3、香港邦联、香港沙田电信、香港大埔、日本东京、日本大阪、新加坡等数据中心...
Hostkey.com成立于2007年的荷兰公司,主要运营服务器出租与托管,其次是VPS、域名、域名证书,各种软件授权等。hostkey当前运作荷兰阿姆斯特丹、俄罗斯莫斯科、美国纽约等数据中心。支持Paypal,信用卡,Webmoney,以及支付宝等付款方式。禁止VPN,代理,Tor,网络诈骗,儿童色情,Spam,网络扫描,俄罗斯色情,俄罗斯电影,俄罗斯MP3,俄罗斯Trackers,以及俄罗斯法...