C#代码以适应文件的地段到DVD尽可能高效地 [英] C#: Code to fit LOTS of files onto a DVD as efficiently as possible

查看:164
本文介绍了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.

推荐答案

简单的算法:


  1. 排序按文件大小的文件列表

  2. 找到的最大文件比DVD上剩余的可用空间变小,并把它添加到DVD。

  3. 如果剩余的DVD自由空间比任何剩余的文件更小,启动一个新的DVD。

  4. 从2重复。

  1. Sort the file list by file size
  2. Find the largest file smaller than the remaining free space on the DVD, and add it to the DVD.
  3. If the remaining DVD free space is smaller than any remaining files, start a new dvd.
  4. Repeat from 2.

这篇关于C#代码以适应文件的地段到DVD尽可能高效地的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆