Pure C language: divide and conquer counterfeit coin problem source sharing

  • 2020-04-02 02:03:21
  • OfStack


#include<stdio.h>
int sum(int m,int n)
{
 if(n==m||n==0)
  return 1;
 else
  return sum(m-1,n)+sum(m-1,n-1);
}
void main()
{
 int m,n;
 printf(" Please enter the number of combinations m : ");
 scanf("%d",&m);
 printf("n Please enter the number of combinations n : ");
 scanf("%d",&n);
 int t=sum(m,n);
 printf("n Combination number results: %dn",t);
}

Related articles: