Derangement Check
Verifies if a given permutation is a derangement.
Controller: CodeCogs
Interface
C++
Derangement Check
boolderangement_check( | int | n | |
int* | a | )[inline] |
Example:
#include <codecogs/maths/combinatorics/permutations/derangement_check.h> #include <iostream> int main() { int x[4] = {4, 3, 2, 1}, y[5] = {1, 3, 2, 5, 4}; std::cout << Maths::Combinatorics::Permutations::derangement_check(4, x) << std::endl; std::cout << Maths::Combinatorics::Permutations::derangement_check(4, y) << std::endl; return 0; }
Output:
1 0
References:
SUBSET, a C++ library of combinatorial routines, http://www.csit.fsu.edu/~burkardt/cpp_src/subset/subset.htmlParameters
n the size of the permutation a the actual permutation given as an array
Returns
- true, if the permutation is a derangement, false otherwise
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.