Advertisement
nguyenhappy92

Tính tổ hợp của n chập k

Nov 9th, 2015
637
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. // Tinh to hop n,k
  2. //
  3. // Khai bao cac ham thu vien neu co
  4. #include<stdio.h>
  5. #include<conio.h>
  6. long giaithua(int x)
  7. {
  8. if(x==0||x==1)
  9. return 1;
  10. else
  11. {
  12. long s=1;
  13. for(int i=2;i<=x;i++)
  14. {
  15. s=s*i;
  16. }
  17. return s;
  18. }
  19. }
  20. void main()
  21. {
  22. long n,k;
  23. scanf("%ld%ld",&n,&k);
  24. double t;
  25. for(int i=0;i<=n;i++)
  26. {
  27. for(int j=0;j<=k;j++)
  28. {
  29. t=(double)(giaithua(i))/((giaithua(k))*(giaithua(i-k)));
  30. }
  31. }
  32. printf("%.0lf",t);
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement