Number of combinations (N choose R) in C++

后端 未结 7 2402
日久生厌
日久生厌 2020-11-27 18:17

Here I try to write a program in C++ to find NCR. But I\'ve got a problem in the result. It is not correct. Can you help me find what the mistake is in the program?

7条回答
  •  清酒与你
    2020-11-27 18:39

    Use double instead of int.

    UPDATE:

    Your formula is also wrong. You should use fact(n)/fact(r)/fact(n-r)

提交回复
热议问题