fork download
  1. #include <stdio.h>
  2.  
  3. int factional(int n){
  4. int i,result=1;
  5. for (i=n;i>1;i--)
  6. result*=i;
  7. return result;
  8. }
  9. int comb(int m, int k){
  10. int result;
  11. result=factional(m)/factional(k)/factional(m-k);
  12. return result;
  13. }
  14. int main(void) {
  15. int m, k;
  16. scanf("%d",&m);
  17. scanf("%d",&k);
  18. printf("%d個の中から%d個を取り出す組み合わせ数は、%d通りです。",m,k,comb(m,k));
  19. return 0;
  20. }
  21.  
Success #stdin #stdout 0s 5264KB
stdin
13
13
stdout
13個の中から13個を取り出す組み合わせ数は、1通りです。