C#代码以适应文件的地段到DVD尽可能高效地

编程入门 行业动态 更新时间:2024-10-07 22:26:03
本文介绍了C#代码以适应文件的地段到DVD尽可能高效地的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我需要编写,将采取文件的列表(有些大,有些小)和适合他们DVD上(或CD,或其他)尽可能高效地应用。此应用程序的整点移动到第三盘,等前移动到第2盘,填补了第2盘起来尽可能之前,使用尽可能多第一盘。

I need to write an application that will take a list of files (some large, some small) and fit them onto DVDs (or CDs, or whatever) as efficiently as possible. The whole point of this application is to use up as much of the 1st disc before moving onto the 2nd disc, filling the 2nd disc up as much as possible before moving onto the 3rd disc, etc.

(注:应用程序没有做实际的刻录到DVD,它只是找出最佳拟合)

(Note: The application doesn't have to do the actual burning to the DVD, it just has to figure out the best possible fit).

我最初以为我通过生成的文件的排列,然后检查每个组合,看看有什么适合最好有一个很好的游戏计划。 (我对这个帮助请求,可以发现的这里)

I initially thought I had a good game-plan by generating a permutation of the files and then checking each combination to see what fits the best. (My request for help on this can be found HERE)

但更多的文件也有,时间越长...指数。所以,我想要一些关于如何最好地实现这个您的意见。

But the more files there are, the longer it takes... exponentially. So I wanted some of your opinions on how to best achieve this.

任何想法? ,并一如既往,C#代码总是赞赏

Any ideas? And, as always, C# code is always appreciated.

推荐答案

简单的算法:

  • 排序按文件大小的文件列表
  • 找到的最大文件比DVD上剩余的可用空间变小,并把它添加到DVD。
  • 如果剩余的DVD自由空间比任何剩余的文件更小,启动一个新的DVD。
  • 从2重复。
  • Sort the file list by file size
  • Find the largest file smaller than the remaining free space on the DVD, and add it to the DVD.
  • If the remaining DVD free space is smaller than any remaining files, start a new dvd.
  • Repeat from 2.
  • 更多推荐

    C#代码以适应文件的地段到DVD尽可能高效地

    本文发布于:2023-11-29 09:25:36,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1645998.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:高效   地段   代码   文件   以适应

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!