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

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

主站蜘蛛池模板: 健康| 会宁县| 稷山县| 秦皇岛市| 康平县| 玉树县| 丰顺县| 铜鼓县| 无极县| 南昌市| 那曲县| 肥乡县| 汝州市| 昭通市| 灌南县| 大荔县| 历史| 桦川县| 汝南县| 来凤县| 石景山区| 惠安县| 平远县| 松滋市| 开封县| 金门县| 平泉县| 张家港市| 交口县| 赞皇县| 乌审旗| 武威市| 都江堰市| 金昌市| 新和县| 文昌市| 阿尔山市| 呼玛县| 和林格尔县| 房山区| 万宁市|