• PUDN用户
    了解作者
  • C/C++
    开发工具
  • 3KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 6
    下载次数
  • 2018-03-16 10:24
    上传日期
实现最优的资源分配,可以合理的分配资源,在服务器资源配置分配问题上经常用到该算法。
装箱算法源代码C++.rar
  • 装箱算法源代码C++.doc
    27KB
内容介绍
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8"> <meta name="generator" content="pdf2htmlEX"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <link rel="stylesheet" href="https://static.pudn.com/base/css/base.min.css"> <link rel="stylesheet" href="https://static.pudn.com/base/css/fancy.min.css"> <link rel="stylesheet" href="https://static.pudn.com/prod/directory_preview_static/6265ad664c65f412590f0385/raw.css"> <script src="https://static.pudn.com/base/js/compatibility.min.js"></script> <script src="https://static.pudn.com/base/js/pdf2htmlEX.min.js"></script> <script> try{ pdf2htmlEX.defaultViewer = new pdf2htmlEX.Viewer({}); }catch(e){} </script> <title></title> </head> <body> <div id="sidebar" style="display: none"> <div id="outline"> </div> </div> <div id="pf1" class="pf w0 h0" data-page-no="1"><div class="pc pc1 w0 h0"><img class="bi x0 y0 w1 h1" alt="" src="https://static.pudn.com/prod/directory_preview_static/6265ad664c65f412590f0385/bg1.jpg"><div class="c x0 y1 w2 h2"><div class="t m0 x1 h3 y2 ff1 fs0 fc0 sc0 ls0 ws0">&#35013;&#31665;&#38382;&#39064; </div><div class="t m0 x2 h3 y3 ff2 fs0 fc0 sc0 ls0 ws0">&#58881; <span class="ff1">&#38382;&#39064;&#25551;&#36848;&#65306;&#35013;&#31665;&#38382;&#39064;&#21487;&#31616;&#36848;&#22914;&#19979;&#65306;&#35774;&#26377;&#32534;&#21495;&#20026;<span class="_ _0"> </span></span>0<span class="ff1">&#12289;</span>1<span class="ff1">&#12289;&#8230;&#12289;</span>n-1<span class="_ _0"> </span><span class="ff1">&#30340;<span class="_ _0"> </span></span>n<span class="_ _0"> </span><span class="ff1">&#31181;&#29289;&#21697;&#65292;&#20307;&#31215;&#20998;&#21035;&#20026;<span class="_ _0"> </span></span>v0<span class="ff1">&#12289;</span>v1<span class="ff1">&#12289;</span></div><div class="t m0 x3 h3 y4 ff1 fs0 fc0 sc0 ls0 ws0">&#8230;&#12289;<span class="ff2">vn-1</span>&#12290;&#23558;&#36825;<span class="_ _0"> </span><span class="ff2">n<span class="_ _0"> </span></span>&#31181;&#29289;&#21697;&#35013;&#21040;&#23481;&#37327;&#37117;&#20026;<span class="_ _0"> </span><span class="ff2">V<span class="_ _0"> </span></span>&#30340;&#33509;&#24178;&#31665;&#23376;&#37324;&#12290;&#32422;&#23450;&#36825;<span class="_ _0"> </span><span class="ff2">n<span class="_ _0"> </span></span>&#31181;&#29289;&#21697;&#30340;&#20307;&#31215;&#22343;&#19981;&#36229;&#36807;<span class="_ _0"> </span><span class="ff2">V</span>&#65292;&#21363;&#23545;&#20110;</div><div class="t m0 x4 h3 y5 ff2 fs0 fc0 sc0 ls0 ws0">0&#8804;i<span class="ff1">&#65308;</span>n<span class="ff1">&#65292;&#26377;<span class="_ _0"> </span></span>0<span class="ff1">&#65308;</span>vi&#8804;V<span class="ff1">&#12290;&#19981;&#21516;&#30340;&#35013;&#31665;&#26041;&#26696;&#25152;&#38656;&#35201;&#30340;&#31665;&#23376;&#25968;&#30446;&#21487;&#33021;&#19981;&#21516;&#12290;&#35013;&#31665;&#38382;&#39064;&#35201;&#27714;&#20351;&#35013;&#23613;&#36825;<span class="_ _0"> </span></span>n<span class="_ _0"> </span><span class="ff1">&#31181;&#29289;&#21697;&#30340;</span></div><div class="t m0 x5 h3 y6 ff1 fs0 fc0 sc0 ls0 ws0">&#31665;&#23376;&#25968;&#35201;&#23569;&#12290; </div><div class="t m0 x4 h3 y7 ff2 fs0 fc0 sc0 ls0 ws0">&#58881; <span class="ff1">&#33509;&#27599;&#21482;&#31665;&#23376;&#25152;&#35013;&#29289;&#21697;&#29992;&#38142;&#34920;&#26469;&#34920;&#31034;&#65292;&#38142;&#34920;&#39318;&#32467;&#28857;&#25351;&#38024;&#23384;&#20110;&#19968;&#20010;&#32467;&#26500;&#20013;&#65292;&#32467;&#26500;&#35760;&#24405;&#23578;&#21097;&#20313;&#30340;&#31354;&#38388;&#37327;&#21644;&#35813;&#31665;</span></div><div class="t m0 x6 h3 y8 ff1 fs0 fc0 sc0 ls0 ws0">&#23376;&#25152;&#35013;&#29289;&#21697;&#38142;&#34920;&#30340;&#39318;&#25351;&#38024;&#12290;&#21478;&#23558;&#20840;&#37096;&#31665;&#23376;&#30340;&#20449;&#24687;&#20063;&#26500;&#25104;&#38142;&#34920;&#12290;&#20197;&#19979;&#26159;&#25353;&#20197;&#19978;&#31639;&#27861;&#32534;&#20889;&#30340;&#31243;&#24207;&#12290;</div><div class="t m0 x7 h4 y9 ff2 fs0 fc0 sc0 ls0 ws0">include &#58881; &lt;stdio.h&gt; &#58881; &#58881; </div><div class="t m0 x7 h4 ya ff2 fs0 fc0 sc0 ls0 ws0">&#58881; # &#58881; include &#58881; &lt;stdlib.h&gt; &#58881; &#58881; </div><div class="t m0 x7 h4 yb ff2 fs0 fc0 sc0 ls0 ws0">&#58881; typedef &#58881; struct &#58881; ele &#58881; &#58881; </div><div class="t m0 x7 h4 yc ff2 fs0 fc0 sc0 ls0 ws0">&#58881; { &#58881;</div><div class="t m0 x3 h4 yd ff2 fs0 fc0 sc0 ls0 ws0">int &#58881; vno; &#58881; &#58881; </div><div class="t m0 x7 h4 ye ff2 fs0 fc0 sc0 ls0 ws0">&#58881; struct &#58881; ele &#58881; *link; &#58881; &#58881; </div><div class="t m0 x7 h4 yf ff2 fs0 fc0 sc0 ls0 ws0">&#58881; } &#58881;ELE; &#58881; &#58881; </div><div class="t m0 x7 h4 y10 ff2 fs0 fc0 sc0 ls0 ws0">&#58881; typedef &#58881; struct &#58881; hnode &#58881; &#58881; </div><div class="t m0 x7 h4 y11 ff2 fs0 fc0 sc0 ls0 ws0">&#58881; { &#58881;</div><div class="t m0 x7 h4 y12 ff2 fs0 fc0 sc0 ls0 ws0"> int &#58881; remainder; &#58881; &#58881; </div><div class="t m0 x7 h4 y13 ff2 fs0 fc0 sc0 ls0 ws0">&#58881; ELE &#58881; *head; &#58881; &#58881; </div><div class="t m0 x7 h4 y14 ff2 fs0 fc0 sc0 ls0 ws0">&#58881; struct &#58881; hnode &#58881; *next; &#58881; &#58881; </div><div class="t m0 x7 h4 y15 ff2 fs0 fc0 sc0 ls0 ws0">&#58881; } &#58881; HNODE; &#58881; &#58881; </div><div class="t m0 x7 h4 y16 ff2 fs0 fc0 sc0 ls0 ws0">&#58881; &#58881; </div><div class="t m0 x7 h4 y17 ff2 fs0 fc0 sc0 ls0 ws0">&#58881; void &#58881; main() &#58881; &#58881; </div><div class="t m0 x7 h4 y18 ff2 fs0 fc0 sc0 ls0 ws0">&#58881; { </div><div class="t m0 x7 h4 y19 ff2 fs0 fc0 sc0 ls0 ws0">&#58881; int &#58881; n, &#58881; i, &#58881; box_count, &#58881; bo<span class="_ _1"></span>x_volume, &#58881; *a; &#58881; &#58881; </div><div class="t m0 x7 h4 y1a ff2 fs0 fc0 sc0 ls0 ws0">&#58881; HNODE &#58881; *bo<span class="_ _1"></span>x_h, &#58881; *box_t, &#58881; *j; &#58881; &#58881; </div><div class="t m0 x7 h4 y1b ff2 fs0 fc0 sc0 ls0 ws0">&#58881; ELE &#58881; *p, &#58881; *q; &#58881; &#58881; </div><div class="t m0 x7 h3 y1c ff2 fs0 fc0 sc0 ls0 ws0">&#58881; Printf(&#8220;<span class="ff1">&#36755;&#20837;&#31665;&#23376;&#23481;&#31215;</span> <span class="_ _2"></span>&#8221;); &#58881; &#58881; </div><div class="t m0 x7 h4 y1d ff2 fs0 fc0 sc0 ls0 ws0">&#58881; scanf(&#8220;%d&#8221;,&amp;box_volume)<span class="_ _1"></span>; &#58881; &#58881; </div><div class="t m0 x7 h3 y1e ff2 fs0 fc0 sc0 ls0 ws0">&#58881; printf(&#8220;<span class="ff1">&#36755;&#20837;&#29289;&#21697;&#31181;&#25968;</span> <span class="_ _2"></span>&#8221;); &#58881; &#58881; </div><div class="t m0 x7 h4 y1f ff2 fs0 fc0 sc0 ls0 ws0">&#58881; scanf(&#8220;%d&#8221;,&amp;n); &#58881; &#58881; </div><div class="t m0 x7 h4 y20 ff2 fs0 fc0 sc0 ls0 ws0">&#58881; a=(int &#58881; *)malloc(sizeof(int)*n); &#58881; &#58881; </div><div class="t m0 x7 h3 y21 ff2 fs0 fc0 sc0 ls0 ws0">&#58881; printf(&#8220;<span class="ff1">&#35831;&#25353;&#20307;&#31215;&#20174;&#22823;&#21040;&#23567;&#39034;&#24207;&#36755;&#20837;&#21508;&#29289;&#21697;&#30340;&#20307;&#31215;&#65306;&#8221;</span>); &#58881; &#58881; </div><div class="t m0 x7 h4 y22 ff2 fs0 fc0 sc0 ls0 ws0">&#58881;for &#58881; (i=0;i&lt;n;i++) &#58881; scanf(&#8220;%d&#8221;,a+i); &#58881; &#58881; </div><div class="t m0 x7 h4 y23 ff2 fs0 fc0 sc0 ls0 ws0">&#58881; bo<span class="_ _1"></span>x_h=box_t=NULL; &#58881; &#58881; </div><div class="t m0 x7 h4 y24 ff2 fs0 fc0 sc0 ls0 ws0">&#58881; bo<span class="_ _1"></span>x_count=0; &#58881; &#58881; </div><div class="t m0 x7 h4 y25 ff2 fs0 fc0 sc0 ls0 ws0">&#58881; for &#58881; (i=0;i&lt;n;i++) &#58881; &#58881; </div><div class="t m0 x7 h4 y26 ff2 fs0 fc0 sc0 ls0 ws0">&#58881; { &#58881; </div><div class="t m0 x7 h4 y27 ff2 fs0 fc0 sc0 ls0 ws0">p=(ELE &#58881; *)malloc(sizeof(ELE)); &#58881; &#58881; </div><div class="t m0 x7 h4 y28 ff2 fs0 fc0 sc0 ls0 ws0">&#58881; p-&gt;vno=i; &#58881; &#58881; </div><div class="t m0 x7 h4 y29 ff2 fs0 fc0 sc0 ls0 ws0">&#58881; for &#58881; (j=box_h;j!=NULL;<span class="_ _1"></span>j=j-&gt;next) &#58881; &#58881; </div><div class="t m0 x7 h4 y2a ff2 fs0 fc0 sc0 ls0 ws0">&#58881; if &#58881; (j-&gt;remainder&gt;=a[i]) &#58881; br<span class="_ _1"></span>eak; &#58881; &#58881; </div><div class="t m0 x7 h4 y2b ff2 fs0 fc0 sc0 ls0 ws0">&#58881; if &#58881; (j==NULL) &#58881; &#58881; </div><div class="t m0 x7 h4 y2c ff2 fs0 fc0 sc0 ls0 ws0">&#58881; { &#58881; j=(HNODE &#58881; *)malloc(sizeof(HNODE)); &#58881; &#58881; </div></div></div><div class="pi" data-data='{"ctm":[1.611850,0.000000,0.000000,1.611850,0.000000,0.000000]}'></div></div> </body> </html>
评论
    相关推荐
    • Fenzo:Mesos框架的可扩展调度程序
      Fenzo提供了一个基于插件的Java库,该库通过使用各种可能的调度目标(例如装箱,跨资源抽象(例如AWS可用区或数据中心机架)进行平衡),资源相似性和任务来促进将资源调度到任务地区。 Fenzo功能: 它是可与任何...
    • CLR.via.C#.(中文第3版).rar
      21.1.1 从托管堆分配资源 21.2 垃圾回收算法 21.3 垃圾回收与调试 21.4 使用终结操作来释放本地资源 21.4.1 使用CriticalFinalizerObject类型确保终结 21.4.2 SafeHandle类型及其派生类型 21.4.3 使用...
    • 优质面试题资源.zip
      础部分的顺序:基本语法,类相关的语法,内部类的语法,继承相关的语法,异常的语法, 线程的语法,集合的语法,io 的语法,虚拟机方面的语法。 1 、一个".java" 源文件中是否可以包括多个类(不是内部类)?...
    • AIC的Java课程7-12章
       学习使用throw,throws检测抛出异常,使用try,catch捕获处理异常,使用finally子句释放资源。  掌握Java的异常层次结构,辨别checked exception和unchecked exception。  能够分别创建新的异常类,...
    • xmljava系统源码-DotNet-Interview:.Net面试题
      .NET平台的程序会运行在CLR上,CLR自动进行资源分配和垃圾回收,某种程度上分离了系统和应用。 Q:如何对数组的元素进行倒序排列? A:xx.Sort()后xx.Reverse()。 Q:HTTP定义的基本的与服务器交互的方法有? A:4种...
    • 《算法设计与分析导论》(R.C.T.Lee (李家同)等著,王卫东 译)
      5.6 用分支限界策略解决人员分配问题 5.7 用分支限界策略解决旅行商优化问题 5.8 用分支限界策略解决o,1背包问题 5.9 用分支限界方法解决作业调度问题 5.10 a*算法 5.11 用特殊的a*算法解决通道路线问题 5.12...
    • AIC的Java课程1-6章
       学习使用throw,throws检测抛出异常,使用try,catch捕获处理异常,使用finally子句释放资源。  掌握Java的异常层次结构,辨别checked exception和unchecked exception。  能够分别创建新的异常类,...
    • Visual.Basic.2010.&.NET4.高级编程(第6版) 扫描版带书签 2/3
      4.5.2 更快地为对象分配内存 230 4.5.3 垃圾回收器的优化 231 4.6 名称空间 232 4.6.1 名称空间的概念 233 4.6.2 名称空间与引用 236 4.6.3 常用的名称空间 237 4.6.4 导入名称空间并指定别名 239 4.6.5 为...
    • C#高级编程(第6版)
       6.2.2 装箱和拆箱  6.3 对象的相等比较  6.3.1 引用类型的相等比较  6.3.2 值类型的相等比较  6.4 运算符重载  6.4.1 运算符的工作方式  6.4.2 运算符重载的示例:Vector结构  6.5 用户定义的数据类型转换 ...
    • ZxingDemo.rar
      android上使用ZXing识别条形码和二维码,代码简单易懂,相信能帮助读者迅速掌握相关的开发