Código
#include <stdio.h> #include <cstdlib> #include <conio.h> // getc Long int factorial(int n) { if(n<=1)return 1; else return(n*factorial(n-1)); } //calculo de c=n!/r!(n-r)! long int combinatoria (int n, int r) { return (factorial(n)/(factorial(r)*factorial(n-r))); } system("cls"); do{ do{ if (n>=34 || r>=34 ){ printf("\n\n\t\t\t! error !\n\tINGRESE UN NUMERO ENTERO DEL 1 AL 33\n\t !GRACIAS POR SU COMPRENSION!\n\n\t\t"); system ("pause"); } system("cls"); printf("\n\t\t\t###### CALCULO DE COMBINACIONES #######\n"); printf("\t\t\t=======================================\n"); printf("\nINGRESE NUMEROS ENTEROS \n"); printf("\nINGRESE n:\t"); scanf("%d",&n); printf("\nINGRESE r:\t"); scanf("%d",&r); } while ( n >= 34 || r>=34 ); if (n < r){ printf("\n\nNO SE CUMPLE CONDICION PARA LAS TECNICAS DE CONTEO\n\t CONDION= r < n\n\n"); } else { printf("\nRESULTADO DE COMBINATORIA[C]=%d\n" , combinatoria(n,r)); printf("==================================\n\n"); } system ("pause"); }while (n<r);
y ambien tengo que incluir las permutaciones distinguibles pero nose como empezar alguien porfavor q me ayude a mejorar el codigo
Mod: Los códigos deben ir en etiquetas GeSHi
no escribas en mayúsculas