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

  • 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:

主站蜘蛛池模板: 英德市| 大英县| 松原市| 故城县| 榆林市| 米易县| 阳信县| 鄂托克旗| 吐鲁番市| 富锦市| 库尔勒市| 虎林市| 墨脱县| 凤台县| 富宁县| 扎赉特旗| 大冶市| 喀什市| 通州市| 保靖县| 余庆县| 特克斯县| 长子县| 克东县| 岐山县| 玛沁县| 凯里市| 湘乡市| 砀山县| 玉环县| 县级市| 大埔县| 昆山市| 丰宁| 扶风县| 昭觉县| 遂平县| 平塘县| 盱眙县| 准格尔旗| 丹阳市|