2022年首次适应算法,最佳适应算法,最坏适应算法 .pdf
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_05.gif)
《2022年首次适应算法,最佳适应算法,最坏适应算法 .pdf》由会员分享,可在线阅读,更多相关《2022年首次适应算法,最佳适应算法,最坏适应算法 .pdf(8页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、#include #include #define Free 0 /?D ? #define Busy 1 /? ? #define OK 1 / 3 #define ERROR 0 /3? #define MAX_length 640 /? ? ?a640KB typedef int Status; int flag; typedef struct freearea/? ?D? ?11 long size; /? D? long address; /? int state; / ? ElemType; / ?D? ? ?11 typedef struct DuLNode ElemType d
2、ata; struct DuLNode *prior; /? struct DuLNode *next; /o? DuLNode,*DuLinkList; DuLinkList block_first; / ? ? DuLinkList block_last; /?2? ? Status alloc(int);/? ? Status free(int); /? ? Status First_fit(int);/ ? |? Status Best_fit(int); /? |? Status Worst_fit(int); /?2? |? void show();/2? ? Status Ini
3、tblock();/?a ? Status Initblock()/?a ? ? ? ? block_first=(DuLinkList)malloc(sizeof(DuLNode); block_last=(DuLinkList)malloc(sizeof(DuLNode); block_first-prior=NULL; block_first-next=block_last; block_last-prior=block_first; 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - -
4、 第 1 页,共 8 页 - - - - - - - - - block_last-next=NULL; block_last-data.address=0; block_last-data.size=MAX_length; block_last-data.state=Free; return OK; / ? ? Status alloc(int ch) int request = 0; coutrequest; if(request0 |request=0) cout? D?2?o? ?endl; return ERROR; if(ch=2) /? |? if(Best_fit(reques
5、t)=OK) cout?31| ?endl; else cout? ?2? ?endl; return OK; if(ch=3) /?2? |? if(Worst_fit(request)=OK) cout?31| ?endl; else cout? ?2? ?endl; return OK; else /? ? |? if(First_fit(request)=OK) cout?31| ?endl; else cout? ?2? ?data.size=request; temp-data.state=Busy; DuLNode *p=block_first-next; while(p) if
6、(p-data.state=Free & p-data.size=request) /D D?o?o? ?D? p-data.state=Busy; return OK; break; if(p-data.state=Free & p-data.sizerequest) /D?D? ? ?D? D temp-prior=p-prior; temp-next=p; temp-data.address=p-data.address; p-prior-next=temp; p-prior=temp; p-data.address=temp-data.address+temp-data.size; p
7、-data.size-=request; return OK; break; p=p-next; return ERROR; / ? |? Status Best_fit(int request) int ch; /?D? ? DuLinkList temp=(DuLinkList)malloc(sizeof(DuLNode); temp-data.size=request; temp-data.state=Busy; DuLNode *p=block_first-next; DuLNode *q=NULL; /?2? while(p) /3? ?D?o ? if(p-data.state=F
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 2022年首次适应算法 最佳适应算法 最坏适应算法 2022 首次 适应 算法 最佳 最坏
![提示](https://www.taowenge.com/images/bang_tan.gif)
限制150内