Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Combinations
- #include <iostream>
- #include <string>
- using namespace std;
- int nCR(int n, int r){
- if (r == 0 || r == n){
- return 1; //terminate
- }
- else{
- return nCR(n-1, r-1) + nCR(n-1, r); //recursive calls
- }
- }
- int main()
- {
- int res = nCR(3,2);
- cout << res << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement