List of combinations of N balls in M boxes in C++

前端 未结 4 1907
野趣味
野趣味 2021-01-03 08:08

I would like to write a function that generate an array of tuples containing all possible permutations of N balls in M boxes in C++.

The order (Edit : in the resulti

4条回答
  •  伪装坚强ぢ
    2021-01-03 08:31

    List of combinations of N balls in M boxes = k + List of combinations of (N-k) balls in (M-1) boxes for every k from 0 to N. Try code this recursively.

提交回复
热议问题