string[] array = {"01", "02", "03", "04", "05", "06", "07", "08", "09", "10"};
如何生成每组合2/3/8/10的字符串像例如2串每个组合,没有重复/重复,无视位置,使用组合公式nCr = 10!/ 2!(10-2)! = 45个组合。
我需要的输出是这样的:
"01", "02"
"01", "03"
"01", "04"
...
"02", "03" // eliminate the "02","01" 'cause it is same as "01","02" combination
"02", "04"
...
然后,以产生3串的组合,将具有120个组合(根据NCR)。 我需要的输出是这样的:4串
"01","02","03"
"01","02","04"
...
和组合,将具有210个组合,至少,每组合5串的组合,将具有252种组合。
我该怎么写呢?我已经用完了很多循环,看起来真的很乱。
我不明白一切,但它可以帮助你吗?使用两个数字获得ncr Combinaison的功能:http://www.programmingsimplified.com/c/source-code/c-program-find-ncr-and-npr或者:http://www.dreamincode.net/code /snippet2334.htm –
我需要的组合,不是总的组合 –
@TheMouthofaCow类似,但不一样。 – Rawling