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

正文內(nèi)容

第2章線性表習(xí)題與參考題答案(編輯修改稿)

2025-07-23 08:38 本頁(yè)面
 

【文章內(nèi)容簡(jiǎn)介】 uct node *next。 /*指針域*/ } Ploy Node。 約瑟夫環(huán)問(wèn)題 約瑟夫環(huán)問(wèn)題:設(shè)編號(hào)為1,2,3,……,n的n(n0)個(gè)人按順時(shí)針?lè)较驀蝗Γ總€(gè)人持有一個(gè)正整數(shù)密碼。開(kāi)始時(shí)任選一個(gè)正整數(shù)做為報(bào)數(shù)上限m,從第一個(gè)人開(kāi)始順時(shí)針?lè)较蜃?起順序報(bào)數(shù),報(bào)到m是停止報(bào)數(shù),報(bào)m的人出列,將他的密碼作為新的m值,從他的下一個(gè)人開(kāi)始重新從1報(bào)數(shù)。如此下去,直到所有人全部出列為止。令n最大值取30。要求設(shè)計(jì)一個(gè)程序模擬此過(guò)程,求出出列編號(hào)序列。源程序代碼:(在Tubro C )include include struct node{ int number。 /* 人的序號(hào) */ int cipher。 /* 密碼 */ struct node *next。 /* 指向下一個(gè)節(jié)點(diǎn)的指針 */}。struct node *CreatList(int num) /* 建立循環(huán)鏈表 */{ int i。 struct node *ptr1,*head。 if((ptr1=(struct node *)malloc(sizeof(struct node)))==NULL) { perror(malloc)。 return ptr1。 } head=ptr1。 ptr1next=head。 for(i=1。inum。i++) { if((ptr1next=(struct node *)malloc(sizeof(struct node)))==NULL) { perror(malloc)。 ptr1next=head。 return head。 } ptr1=ptr1next。 ptr1next=head。 } return head。}main(){ int i,n=30,m。 /* 人數(shù)n為30個(gè) */ struct node *head,*ptr。 randomize()。 head=CreatList(n)。 for(i=1。i=30。i++) { headnumber=i。 headcipher=rand()。 head=headnext。 } m=rand()。 /* m取隨機(jī)數(shù) */ i=0。 /* 因?yàn)槲覜](méi)辦法刪除head指向的節(jié)點(diǎn),只會(huì)刪除head的下一節(jié)點(diǎn),所以只能從0數(shù)起。*/ while(headnext!=head) /* 當(dāng)剩下最后一個(gè)人時(shí),退出循環(huán) */ { if(i==m) { ptr=headnext。 /* ptr記錄數(shù)到m的那個(gè)人的位置 */ printf(number:%d\n,ptrnumber)。
點(diǎn)擊復(fù)制文檔內(nèi)容
公司管理相關(guān)推薦
文庫(kù)吧 www.dybbs8.com
備案圖片鄂ICP備17016276號(hào)-1