官术网_书友最值得收藏!

  • The Modern C# Challenge
  • Rod Stephens
  • 118字
  • 2021-08-13 15:23:51

3. Combinations

A combination is an unordered selection of objects from a set. For example, if the set is {apple, banana, cherry}, then the combinations containing two items are all of the subsets containing two items in any order. Those combinations are {apple, banana}, {apple, cherry}, and {banana, cherry}. This time, {apple, banana} and {banana, apple} are considered the same, so the combinations only include one of those subsets.

Write an extension method that returns a List<List<T>>, holding the combinations of a specified length from an array of items. If the specified length is zero, return all combinations of all lengths.

Write a program similar to the one shown in the following screenshot to test your method:

主站蜘蛛池模板: 壤塘县| 麻江县| 阳信县| 博白县| 平度市| 井冈山市| 陵川县| 北碚区| 新蔡县| 井陉县| 上栗县| 文化| 壶关县| 五大连池市| 安达市| 江油市| 上思县| 江城| 周宁县| 商河县| 宜春市| 巴南区| 巴东县| 会同县| 团风县| 西安市| 乌鲁木齐县| 防城港市| 金秀| 吐鲁番市| 台山市| 射洪县| 资阳市| 五原县| 康保县| 子长县| 贞丰县| 德兴市| 卢氏县| 定南县| 胶州市|