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

正文內(nèi)容

課程設(shè)計哲學(xué)家就餐問題-閱讀頁

2025-01-25 10:57本頁面
  

【正文】 sopher { private: int number。 /*標(biāo)記當(dāng)前哲學(xué)家的狀態(tài) ,0 表示正在等待 (即處于 饑餓狀態(tài) ),1 表示得到兩支筷子正在吃飯 ,2 表示正在思考 */ public: Philosopher(int num=0): status(2), number(num) { } 11 int find() const { return number。 } void Change() 。 void Philosopher::Change() { EnterCriticalSection (amp。 //進(jìn)入臨界區(qū) if(status==1) //正在進(jìn)餐 { tools[number%6]=true。 //放下右手工具 status=2。 //改變狀態(tài)為等待 } else if(status==0) //等待中 { if(tools[number%6]amp。tools[(number1)%6]) //左右手兩邊工具均為空閑狀態(tài) { tools[number%6]=false。 //拿起右手工具 status=1。cs) 。 int i=pAgetinfo()。 if(i==0) str=等待 。 else str=思考 。 } string toolstatus(bool a) { string state。 if(a==false) state=用 。 } int main() { 13 char con = 39。 //判斷是否繼續(xù) for(int i=0。i++) tools[i]=true。 InitializeCriticalSection (amp。 //初始化初始化臨界區(qū) cout狀態(tài)說明示意圖: endl。 cout哲學(xué)家 5 號的狀態(tài) 叉 3 的狀態(tài) 刀 1的狀態(tài) 哲學(xué)家 1 號的狀態(tài) endl。 cout哲學(xué)家 4 號的狀態(tài) 叉 2 的狀態(tài) 刀 2的狀態(tài) 哲學(xué)家 2 號的狀態(tài) endl。 cout餐具的狀態(tài), \“用 \”表示使用中, \“閑 \”表示空閑中。 coutendl。 coutendl。 while(con==39。) { ()。 ()。 14 ()。 cout當(dāng)前狀態(tài)為: endl。P1) endl。P6) toolstatus(tools[0]) toolstatus(tools[1]) ()print(amp。 cout toolstatus(tools[5]) toolstatus(tools[2])endl。P5) toolstatus(tools[4]) toolstatus(tools[3]) ()print(amp。 cout ()print(amp。 coutendl。 cincon。 } DeleteCriticalSection (amp。 //退出資源區(qū) return 0。 通過這次課程設(shè)計,我學(xué)到了許多課本上學(xué)不 到的知識,注意到了許多課本上沒有提到的東西。正所謂“實踐出真知”,有些代碼看上去沒什么問題,但是實際運(yùn)行起來就是不出正確結(jié)果。 設(shè)計中總會遇到這樣那樣的問題,遇到問題勢必要自己分析問題,通過各種渠道解決問題,比如利用互聯(lián)網(wǎng)。有些時候,學(xué)習(xí)到的知識是次要的,重要 的是學(xué)習(xí)知識的方
點擊復(fù)制文檔內(nèi)容
試題試卷相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1