fork download
  1. // Level 3
  2. #include <stdio.h>
  3.  
  4. int combi(int n, int r)
  5. {
  6. int i, s = 1;
  7. for (i = n; i >= r + 1; i--) {
  8. s *= i;
  9. }
  10. for (i = n - r; i >= 2; i--) {
  11. s /= i;
  12. }
  13. return s;
  14. }
  15.  
  16. int main()
  17. {
  18. int n, r;
  19.  
  20. for (n = 0; n <= 5; n++) {
  21. for (r = 0; r <= n; r++) {
  22. printf("%dC%d= %-3d", n, r, combi(n, r));
  23. }
  24. printf("\n");
  25. }
  26. return 0;
  27. }
  28.  
Success #stdin #stdout 0.02s 1676KB
stdin
Standard input is empty
stdout
0C0= 1  
1C0= 1  1C1= 1  
2C0= 1  2C1= 2  2C2= 1  
3C0= 1  3C1= 3  3C2= 3  3C3= 1  
4C0= 1  4C1= 4  4C2= 6  4C3= 4  4C4= 1  
5C0= 1  5C1= 5  5C2= 10 5C3= 10 5C4= 5  5C5= 1