Write a C++ program to implement an algorithm that generates the factorial representation of a natural number k. and generates the permutation of rank k in the lexicographic order of the permutations of an n-set. You must first prompt the user for the value of n, then for value(s) of k. Remember to use the alphabet for the elements of your permutation.
As an example, the factoradic number 2110_! is equal to
2 x 3! + 1 x 2! + 1 x 1! + 0 x 0!
= 2 x 6 + 1 x 2 + 1 x 1 + 0 x 1
= 12 + 2 + 1 + 0
= 15
Eg string like {A…..Z}.. A[26]… n= index; so if n=4 is n= {A,B,C} and n =4 {A,C,B,D}…..
Comments
Leave a comment