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

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

2. Permutations

A permutation is an ordering of a selection of objects from a set. For example, suppose the set is {apple, banana, cherry}, then the permutations containing two items are all of the orderings of two items selected from that set. Those permutations are {apple, banana}, {apple, cherry}, {banana, apple}, {banana, cherry}, {cherry, apple}, and {cherry, banana}. Notice that {apple, banana} and {banana, apple} contain the same items in different orders.

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

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

主站蜘蛛池模板: 和田市| 韩城市| 阜阳市| 东至县| 宣化县| 兴业县| 大城县| 武冈市| 中阳县| 红原县| 彩票| 上蔡县| 崇州市| 车险| 博客| 舒兰市| 汤阴县| 宜兰市| 新巴尔虎右旗| 高州市| 桃园市| 芒康县| 达日县| 太保市| 开江县| 永州市| 塔城市| 伊宁县| 仁寿县| 调兵山市| 蛟河市| 南充市| 卫辉市| 五家渠市| 洛隆县| 桐乡市| 兴隆县| 平陆县| 苗栗市| 莲花县| 囊谦县|