数学趣题——计算组合数

   1: #include "stdio.h"
   2:  
   3: int cnr(int m, int n)
   4: {
   5:     if(m == n || n == 0)
   6:         return 1;
   7:     else
   8:         return cnr(m - 1, n) + cnr(m - 1, n - 1);
   9: }
  10:  
  11: int main()
  12: {
  13:     int m, n;
  14:     printf("Please input m and n for C(m,n)\n");
  15:     scanf("%d %d", &m, &n);
  16:     printf("C(%d,%d)=%d", m, n, cnr(m, n));
  17:     return 0;
  18: }

你可能感兴趣的:(数学)