实现代码:
#include#include #include #define MAX_WIN 20 #define MAX_STAY 100 typedefstructcustomer *link; structcustomer { intstay; link next; }; link GUY(intstay, link next) { link c =malloc(sizeof*c); c->stay = stay; c->next = next; returnc; } link win[MAX_WIN]; voidmorning() { inti; for(i = 0; i < MAX_WIN; i++) { win[i] = NULL; } } voidcome(intw,intstay) { if(win[w] == NULL) { win[w] = GUY(stay, NULL); win[w]->next = win[w]; } else win[w] = win[w]->next = GUY(stay, win[w]->next); } voidleave(intw) { if(win[w]->next == win[w]) { free(win[w]); win[w] = NULL; } else { link t = win[w]->next; win[w]->next = t->next; free(t); } } voidguys() { inti; link t; system("clear"); for(i = 0; i < MAX_WIN; i++,puts(" ")) { printf("WIN%3d:_", i); if((t = win[i]) == NULL) continue; for(; t->next != win[i]; t = t->next) { printf("%4d", t->next->stay); } } Sleep(1); } voidlater() { inti; for(guys(), i = 0; i < MAX_WIN; i++) { if(win[i] == NULL) continue; if(win[i]->next->stay > 0) (win[i]->next->stay)--; else leave(i); } } intmain() { srand(time(NULL)); for(morning; ;later()) { come(rand()%MAX_WIN,rand()%MAX_STAY+1); } return0; }
由于这里是生成的随机数,所以程序会一直在变化。按住ctrl +c 终止程序
孢子2生物进化中文版(Spores)
孢子2生物进化中文版让我们来做一回疯狂的博士,打造一个属于自
叫我万岁爷九游官方版
叫我万岁爷带你体验当换地点感觉,全新的模拟手游大作让你开始一
梦回凤歌
梦回凤歌手游中你将步入古代的宫廷纷争之中,本想度过美好幸福的
洋果子店rose最新版本
洋果子店最新版是一款十分容易让人垂涎的开店经营类手游。游戏玩
明日大亨最新版
明日大亨手游,一个非常经典有趣的模拟经营类型的商战手游,在游