PERMUTATION PROGRAM


Permutation is to combine several objects from a group with respect to the order. In the permutation, the order observed. {1,2,3} is not equal to {2,3,1} and {3,1,2} Example: There is a box of 3 balls each of red, green and blue. If a child is assigned to take 2 balls at random and the order taking note, how many permutations are there? Solution: There are 6 permutations, namely: MH, MB, HM, HB, BM, BH.

Here is one example of his program:

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

int factorial (int x);
void main ()
{
     int n, r, Permutation;
     court <<"\ t \ tSlamet Islan Al Hidayah" <<endl;
     court <<"\ t \ t 10018075" <<endl;
     court <<endl;
     court <<"Counting Permutation Program (NPR)" <<endl;
     court <<endl;
     court <<"Enter a value of n:"; cin>> n;
     court <<"Enter a value of r:"; cin>> r;
     court <<endl;
     Permutations = factorial (n) / factorial (n-r);
     court <<"permutations is:" <<Permutation;
     getch ();
     }

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

return (fak);
}
Output :
 
If the sequence of note and every object that is available can be selected or used only once then the number of permutations that exist are:
 
  Where n is the number of objects you can choose, r is the amount that must be selected and! is the factorial symbol. For example, there is a vote in an organization. Candidates can choose any five people. Who gets the most votes will be appointed chairman of the organization. Who received the second most votes will be appointed vice chairman. And the third most votes will be the secretary. How many voting results that might happen? Using the formula above, there are 5! / (5-3)! = 60 permutations. Suppose that if n = r (which indicates that the number of objects that can be selected equal to the amount that must be selected) then the formula becomes:

because 0! = 1! = 1
For example, there are five empty boxes available. The five empty boxes must be filled in (there should not be empty). The five empty boxes should only be filled with the numbers 1,2,3,4,5. How many ways to fill the empty box? By using the formula n! then there are 5! = 120 permutations.

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 " PERMUTATION PROGRAM "