COMBINATION PROGRAM

The combination is to combine several objects from a group without regard to order. In combination, the order is not considered. {1,2,3} is equal to {2,3,1} and {3,1,2}. Example: A child may only take two envelopes of the three envelopes provided by the envelope A, envelope B and C. The envelope Determine how many combinations to take the two envelopes of the three envelope provided?
Solution: There are three combinations, namely: A, B, A-C and B-C.
The following is a program of combinmasi please understand may help your problem:


# include <iostream>
# include <conio.h>

int factorial (int x);
void main ()
{
     int n, r, combination;
     court <<"\ t \ tSlamet Islan Al Hidayah" <<endl;
     court <<"\ t \ t 10018075" <<endl;
     court <<endl;
     court <<"Calculating Combination Program (NCR)" <<endl;
     court <<endl;
     court <<"Enter a value of n:"; cin>> n;
     court <<"Enter a value of r:"; cin>> r;
     combination = factorial (n) / (factorial (r) * factorial (nr));
     court <<endl;
     court <<"The combination is:" <<combination;
     getch ();
     }

int factorial (int n) {
     int fak;
     if (n <= 1) {
     fak = 1;}
     else {
     fak = n * factorial (n-1);}

return (fak);
}
Output :

Well that's the program that I can make,,,,,!

If there are less jelass know any mistake, do not hesitate to leave a comment ataun advice. So that I can fix it later terimakasihh over his visit,,

Regards super ..


0 Response to " COMBINATION PROGRAM "