Unrank
Returns the permutation of the given rank, as generated by the Permutation Class 2 component.
Controller: CodeCogs
Contents
Interface
C++
Unknown
std::vector<int> unrankunknown( | int | n | |
int | rank | ) |
Example:
#include <codecogs/maths/combinatorics/permutations/unrank.h> #include <iostream> int main() { std::cout << "The permutation of 10 elements and rank 124 is:"; std::cout << std::endl; std::vector<int> result = Maths::Combinatorics::Permutations::unrank(10, 124); for (int i = 0; i < result.size(); i++) std::cout << result[i] << " "; std::cout << std::endl; return 0; }
Output:
The permutation of 10 elements and rank 124 is: 1 2 3 9 4 5 10 6 8 7
References:
SUBSET, a C++ library of combinatorial routines, http://www.csit.fsu.edu/~burkardt/cpp_src/subset/subset.htmlReturns
- the permutation of size n and given rank, as generated by the <em> Permutation Class 2 </em> component
Authors
- Lucian Bentea (August 2005)
Source Code
Source code is available when you agree to a GP Licence or buy a Commercial Licence.
Not a member, then Register with CodeCogs. Already a Member, then Login.