freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

應(yīng)用數(shù)據(jù)結(jié)構(gòu)實驗指導書-文庫吧

2025-06-08 17:25 本頁面


【正文】 stack[i])。}/*置空順序棧*/void setEmpty(SqStack *p){ ptop=1。} /*主函數(shù)*/main(){ SqStack *q。 int y, cord。 ElemType a。 do { printf(\n第一次使用必須初始化!\n)。 printf(\n)。 printf(\n 主菜單\n)。 printf(\n 1 初始化順序棧\n)。 printf(\n 2 插入一個元素\n)。 printf(\n 3 刪除棧頂元素\n)。 printf(\n 4 取棧頂元素\n)。 printf(\n 5 置空順序棧\n)。 printf(\n 6 結(jié)束程序運行\(zhòng)n)。 printf(\n\n)。 printf(請輸入您的選擇( 1, 2, 3, 4, 5, 6): )。 scanf(%d, amp。cord)。 printf(\n)。 switch(cord) { case 1: { q=(SqStack*)malloc(sizeof(SqStack))。 InitStack(q)。 OutStack(q)。 } break。 case 2: { printf(請輸入要插入的數(shù)據(jù)元素:a=)。 scanf(%d,amp。a)。 Push(q, a)。 OutStack(q)。 } break。 case 3: { Pop(q)。 OutStack(q)。 } break。 case 4: { y=GetTop(q)。 printf(\n棧頂元素為:%d\n, y)。 OutStack(q)。 } break。 case 5: { setEmpty(q)。 printf(\n 順序棧被置空!\n)。 OutStack(q)。 } break。 case 6: exit(0)。 } } while (cord=6)。}C.隊列部分——熟悉講義中隊列的各種基本運算,并在此基礎(chǔ)上設(shè)計一個主程序,完成如下功能:① 模擬一個機場飛機起降的過程② 機場僅有一條跑道,要求起飛與降落不能同時進行③ 進場飛機若暫時沒有跑道可用須在空中盤旋等候④ 離場飛機若暫時沒有跑道可用須在地面排隊等候⑤ 僅當空中無飛機等待降落時地面飛機方可起飛⑥ 飛機的申請進場、降落、申請離場和起飛分別視為獨立事件⑦ 每個事件的發(fā)生占用一個時間單位。除降落和起飛外,各事件可以同時發(fā)生【參考程序】define MAXQUEUE 5 /* use a small value for testing */include include include include include include include typedef enum boolean { False, True } Boolean。typedef enum action { ARRIVE, DEPART } Action。typedef struct plane{ int id。 /* identification number of airplane */ int tm。 } Plane。 /* time of arrival in queue */typedef Plane QueueEntry。typedef struct queue{ int count。 /* number of airplanes in the queue */ int front, rear。 /* front and rear of the queue */ QueueEntry entry[MAXQUEUE]。 } Queue。/* CreateQueue: create the queue. Pre: None. Post: The queue q has been initialized to be empty. */void CreateQueue(Queue *q){ qcount=qfront=0。 qrear=1。}/* Error: display an error message. Pre: message is the error message to display. Post: The error message has been printed to stderr and the program terminates. */void Error(char *message){ fprintf(stderr, Error: %s\n, message)。 exit (1)。}/* UserSaysYes: True if the user wants to continue execution. Pre: None. Post: Returns True if the user39。s answer begins with either y or Y, False if the user responds with any response beginning with either n or N.*/Boolean UserSaysYes(void){ int c。 printf( (y/n)? )。 do { while ((c=getchar())==39。\n39。) 。 /* Ignore new line character. */ if (c==39。y39。 || c==39。Y39。 || c==39。n39。 || c==39。N39。) return (c==39。y39。 || c==39。Y39。)。 printf(Please respond by typing one of the letters y or n\n)。 } while (1)。}/* Randomize: set staring point for pseudorandom integers. */void Randomize(void){ srand((unsigned int)(time(NULL)%10000))。}/* Start: print messages and initialize the parameters. Pre: None. Post: Asks user for responses and initializes all variables specified as parameters. Uses: UserSaysYes. */void Start(int *endtime, double *expectarrive, double *expectdepart){ Boolean ok。 printf( This program simulates an airport with only one runway.\n One plane can land or depart in each unit of time.\n Up to %d planes can be waiting to land or take off at any time.\n, MAXQUEUE)。 printf( How many units of time will the simulation run? )。 scanf(%d, endtime)。 Randomize()。 /* Initialize random number generation. */ do { printf( Expected number of arrivals per unit time (real number)? )。 scanf(%lf, expectarrive)。 printf( Expected number of departures per unit time? )。 scanf(%lf, expectdepart)。 if (*expectarrive || *expectdepart) { printf( These numbers must be nonnegative.\n)。 ok=False。 } else if (*expectarrive+*expectdepart) { printf( The airport will bee saturated. Read new numbers?)。 ok=!UserSaysYes( )。 } else ok=True。 } while (ok==False)。 printf(\n)。}/* PoissonRandom: generate a pseudorandom integer according to the Poisson distribution. Pre: None. Post: generate a random nonnegative integer according to a Poisson distribution with the expected value given as the parameter. Uses: exp, rand. */int PoissonRandom(double expectedvalue){ int n=0。 /* counter of iterations */ double limit=exp(expectedvalue)。 /* ev, v is the expected value */ double x=rand()/(double) INT_MAX。 /* pseudorandom number */ while (xlimit) { n++。 x*=rand()/(double) INT_MAX。 } return n。}/* NewPlane: make a new record for a plane, update nplanes. Pre: None. Post: Makes a new structure for a plane and updates nplanes. */void NewPlane(Plane *p, int *nplanes, int curtime, Action kind){ ++*nplanes。 pid=*nplanes。 ptm=curtime。 switch(kind) { case ARRIVE: printf( Plane %3d ready to land.\n, *nplanes)。 break。 case DEPART: printf( Plane %3d ready to take off.\n, *nplanes)。 break。 }}/* QueueEmpty: returns nonzero if the queue is empty. Pre: The queue q has been created. Post: It returns nonzero if the queue is empty, zero otherwise. */Boolean QueueEmpty(Queue *q){ return qcount=0。}/* QueueFull: returns nonzero if the queue is full. Pre: The queue q has been created. Post: It returns nonzero if the queue is full, zero otherwise. */Boolean QueueFull(Queue *q){ return qcount=MAXQUEUE。}/* Appe
點擊復制文檔內(nèi)容
環(huán)評公示相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1