fork download
  1. #include <stdio.h>
  2.  
  3. int combinatoryPDA (int n,int k){
  4. int i,j;
  5. int coeff[n][k];
  6.  
  7. printf("Introduce the upper part \n");
  8. scanf("%d",&n);
  9. printf("Introduce the lower part \n");
  10. scanf("%d",&k);
  11. printf("Will compute this \n(%d)\n(%d)\n",n,k);
  12.  
  13. //USAMOS LOS CASOS BASE PARA RELLENAR LA TABLA E IR COGIENDO LOS VALORES
  14. //DE ESTA PARA CALCULAR LO QUE NOS DARÁ EL ALGORITMO DE COMBINATORIA.
  15. for(i = 0 ; i < n ; i++){
  16. for(j = 0 ; j < k ; j++)
  17. if(i == 0 || i < j){
  18. coeff[i][j] = 0;//CASO BASE 1
  19. }
  20. else if(i > 0){
  21. coeff[i][0] = 1;//CASO BASE 2
  22. }
  23. else if(j == 1){
  24. coeff[i][1] = n;//CASO BASE 3
  25. }
  26. else if(i == j){
  27. coeff[i][i] = 1;//CASO BASE 4
  28. }
  29. else{
  30. coeff[i][j] = coeff[i-1][j-1]+coeff[i-1][j];//ALGORITMO PARA LA BUSQUEDA EN LA TABLA DE LOS VALORES
  31. }
  32. //return coeff[N][K];
  33. printf("%d",coeff[i][j]);
  34. }
  35.  
  36. }
  37.  
  38. int main(void) {
  39. int n,k;
  40.  
  41. combinatoryPDA (n,k);
  42.  
  43. return 0;
  44. }
  45.  
Success #stdin #stdout 0s 9416KB
stdin
Standard input is empty
stdout
Introduce the upper part 
Introduce the lower part 
Will compute this 
(0)
(0)