{"id":75430,"date":"2023-12-27T22:03:54","date_gmt":"2023-12-27T14:03:54","guid":{"rendered":"https:\/\/www.techphant.cn\/?p=75430"},"modified":"2024-03-27T17:29:10","modified_gmt":"2024-03-27T09:29:10","slug":"syzhsysfdmdyy","status":"publish","type":"post","link":"https:\/\/www.techphant.cn\/blog\/75430.html","title":{"rendered":"\u4f7f\u7528\u6700\u574f\u9002\u5e94\u7b97\u6cd5\u4ee3\u7801\u7684\u5e94\u7528"},"content":{"rendered":"

  \u6700\u574f\u9002\u5e94\u7b97\u6cd5\u662f\u4e00\u79cd\u7528\u4e8e\u52a8\u6001\u5206\u533a\u5b58\u50a8\u7ba1\u7406\u7684\u5185\u5b58\u5206\u914d\u7b97\u6cd5\u3002\u4eca\u5929\u6211\u4eec\u5c06\u4ecb\u7ecd\u6700\u574f\u9002\u5e94\u7b97\u6cd5\u7684\u539f\u7406\u4ee5\u53ca\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\u7684\u76f8\u5173\u6848\u4f8b\u3002<\/p>\n

\u6700\u574f\u9002\u5e94\u7b97\u6cd5\u7b80\u4ecb<\/h2>\n

  \u6700\u574f\u9002\u5e94\u7b97\u6cd5\u662f\u4e00\u79cd\u7528\u4e8e\u52a8\u6001\u5206\u533a\u5b58\u50a8\u7ba1\u7406\u7684\u7b97\u6cd5\u3002\u5b83\u4e3b\u8981\u7528\u4e8e\u5185\u5b58\u7ba1\u7406\uff0c\u80fd\u591f\u6709\u6548\u5730\u5904\u7406\u52a8\u6001\u53d8\u5316\u7684\u5185\u5b58\u9700\u6c42\u3002\u6700\u574f\u9002\u5e94\u7b97\u6cd5\u7684\u6838\u5fc3\u601d\u60f3\u662f\u9009\u62e9\u6700\u5927\u7684\u53ef\u7528\u5206\u533a\u6765\u6ee1\u8db3\u5f53\u524d\u8bf7\u6c42\uff0c\u8fd9\u6837\u53ef\u4ee5\u6700\u5927\u7a0b\u5ea6\u5730\u51cf\u5c11\u788e\u7247\u95ee\u9898\u3002<\/p>\n

  \u7b97\u6cd5\u539f\u7406<\/h3>\n

  \u6700\u574f\u9002\u5e94\u7b97\u6cd5\u7684\u5b9e\u73b0\u4f9d\u8d56\u4e8e\u5bf9\u53ef\u7528\u5185\u5b58\u5757\u8fdb\u884c\u6392\u5e8f\uff0c\u901a\u5e38\u4f7f\u7528\u4f18\u5148\u961f\u5217\u6216\u5176\u4ed6\u6570\u636e\u7ed3\u6784\u6765\u5b9e\u73b0\u3002\u5f53\u6709\u65b0\u7684\u5185\u5b58\u8bf7\u6c42\u65f6\uff0c\u7b97\u6cd5\u4f1a\u9009\u62e9\u6700\u5927\u7684\u53ef\u7528\u5206\u533a\u6765\u5206\u914d\u7ed9\u8bf7\u6c42\uff0c\u4ee5\u5c3d\u91cf\u51cf\u5c11\u5206\u914d\u540e\u5269\u4f59\u7684\u788e\u7247\u7a7a\u95f4\u3002<\/p>\n

  \u4ee3\u7801\u5b9e\u73b0<\/h3>\n

  \u4ee5\u4e0b\u662f\u6700\u574f\u9002\u5e94\u7b97\u6cd5\u7684\u7b80\u5355\u4ee3\u7801\u5b9e\u73b0\uff1a<\/p>\n

  void worst_fit(int blockSize[], int m, int processSize[], int n) {<\/p>int allocation[n];<\/p>memset(allocation, -1, sizeof(allocation));<\/p> for (int i=0; i= processSize[i]) { if (wstIdx == -1) {<\/p> wstIdx = j;<\/p> } else if (blockSize[wstIdx] < blockSize[j]) {<\/p> wstIdx = j;<\/p> }<\/p> }<\/p> }<\/p> if (wstIdx != -1) {<\/p> allocation[i] = wstIdx;<\/p> blockSize[wstIdx] -= processSize[i];<\/p> }<\/p>}<\/p>\/\/ \u8f93\u51fa\u5206\u914d\u7ed3\u679c<\/p>cout << \"\u8fdb\u7a0b\u53f7 t \u8fdb\u7a0b\u5927\u5c0f t \u5206\u533a\u53f7n\";<\/p> for (int i=0; i<\/n;><\/n;><\/code><\/pre>\n

\u6700\u574f\u9002\u5e94\u7b97\u6cd5\u7684\u5e94\u7528<\/h2>\n

  \u6700\u574f\u9002\u5e94\u7b97\u6cd5\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\u6709\u7740\u5e7f\u6cdb\u7684\u5e94\u7528\u573a\u666f\uff0c\u4f8b\u5982\u5728\u64cd\u4f5c\u7cfb\u7edf\u5185\u5b58\u7ba1\u7406\u3001\u52a8\u6001\u94fe\u63a5\u5e93\u52a0\u8f7d\u3001\u4ee5\u53ca\u5d4c\u5165\u5f0f<\/a>\u7cfb\u7edf\u4e2d\u7684\u8d44\u6e90\u5206\u914d\u7b49\u65b9\u9762\u3002<\/p>\n

  \u64cd\u4f5c\u7cfb\u7edf\u5185\u5b58\u7ba1\u7406<\/h3>\n

  \u5728\u64cd\u4f5c\u7cfb\u7edf\u4e2d\uff0c\u6700\u574f\u9002\u5e94\u7b97\u6cd5\u88ab\u7528\u4e8e\u52a8\u6001\u5185\u5b58\u5206\u914d\u3002\u5f53\u8fdb\u7a0b\u7533\u8bf7\u5185\u5b58\u65f6\uff0c\u64cd\u4f5c\u7cfb\u7edf\u4f1a\u4f7f\u7528\u6700\u574f\u9002\u5e94\u7b97\u6cd5\u6765\u9009\u62e9\u9002\u5408\u7684\u5185\u5b58\u5757\uff0c\u4ee5\u4f18\u5316\u5185\u5b58\u7684\u5229\u7528\u7387\u548c\u51cf\u5c11\u788e\u7247\u3002<\/p>\n

  \u52a8\u6001\u94fe\u63a5\u5e93\u52a0\u8f7d<\/h3>\n

  \u52a8\u6001\u94fe\u63a5\u5e93\u5728\u52a0\u8f7d\u65f6\u9700\u8981\u8fdb\u884c\u5185\u5b58\u5206\u914d\uff0c\u6700\u574f\u9002\u5e94\u7b97\u6cd5\u53ef\u4ee5\u5728\u52a0\u8f7d\u8fc7\u7a0b\u4e2d\u9009\u62e9\u5408\u9002\u7684\u5185\u5b58\u5757\u6765\u5b58\u653e\u52a8\u6001\u94fe\u63a5\u5e93\uff0c\u4ece\u800c\u63d0\u9ad8\u7cfb\u7edf\u7684\u6027\u80fd\u548c\u8d44\u6e90\u5229\u7528\u7387\u3002<\/p>\n

\u603b\u7ed3<\/h2>\n

  \u6700\u574f\u9002\u5e94\u7b97\u6cd5\u662f\u4e00\u79cd\u9ad8\u6548\u7684\u52a8\u6001\u5206\u533a\u5b58\u50a8\u7ba1\u7406\u7b97\u6cd5\uff0c\u5176\u6838\u5fc3\u601d\u60f3\u662f\u9009\u62e9\u6700\u5927\u7684\u53ef\u7528\u5206\u533a\u6765\u6ee1\u8db3\u5f53\u524d\u8bf7\u6c42\uff0c\u4ee5\u5c3d\u91cf\u51cf\u5c11\u5206\u914d\u540e\u5269\u4f59\u7684\u788e\u7247\u7a7a\u95f4\u3002<\/strong>\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u6700\u574f\u9002\u5e94\u7b97\u6cd5\u88ab\u5e7f\u6cdb\u5e94\u7528\u4e8e\u64cd\u4f5c\u7cfb\u7edf\u5185\u5b58\u7ba1\u7406\u3001\u52a8\u6001\u94fe\u63a5\u5e93\u52a0\u8f7d\u4ee5\u53ca\u5d4c\u5165\u5f0f\u7cfb\u7edf\u4e2d\u7684\u8d44\u6e90\u5206\u914d\u7b49\u65b9\u9762\uff0c\u4e3a\u7cfb\u7edf\u7684\u6027\u80fd\u548c\u8d44\u6e90\u5229\u7528\u7387\u63d0\u4f9b\u4e86\u6709\u6548\u7684\u652f\u6301\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u6700\u574f\u9002\u5e94\u7b97\u6cd5\u662f\u4e00\u79cd\u7528\u4e8e\u52a8\u6001\u5206\u533a\u5b58\u50a8\u7ba1\u7406\u7684\u5185\u5b58\u5206\u914d\u7b97\u6cd5\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u6700\u574f\u9002\u5e94\u7b97\u6cd5\u7684\u539f\u7406\u4ee5\u53ca\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\u7684\u76f8\u5173\u6848\u4f8b\u3002\u6700\u574f\u9002\u5e94\u7b97\u6cd5\u7b80\u4ecb\u6700\u574f\u9002\u5e94\u7b97\u6cd5\u662f\u4e00\u79cd\u7528\u4e8e\u52a8\u6001\u5206\u533a\u5b58\u50a8\u7ba1<\/p>\n","protected":false},"author":1,"featured_media":64183,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-global-header-display":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","footnotes":""},"categories":[36],"tags":[305,395],"class_list":["post-75430","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","tag-dzjs","tag-algorithm"],"_links":{"self":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/posts\/75430","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/comments?post=75430"}],"version-history":[{"count":0,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/posts\/75430\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/media\/64183"}],"wp:attachment":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/media?parent=75430"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/categories?post=75430"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/tags?post=75430"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}