Check
Checks whether an array represents a permutation.
Controller: CodeCogs
Contents
Interface
C++
Check
boolcheck( | int | n | |
int* | p | ) |
Example:
#include <codecogs/maths/combinatorics/permutations/check.h> #include <iostream> int main() { int sigma[5] = {1, 3, 2, 3, 4}, tau[4] = {4, 3, 2, 1}; std::cout << "Sigma is "; std::cout << (Maths::Combinatorics::Permutations::check(5, sigma) ? "" : "not "); std::cout << "a valid permutation."; std::cout << std::endl; std::cout << "Tau is "; std::cout << (Maths::Combinatorics::Permutations::check(4, tau) ? "" : "not "); std::cout << "a valid permutation."; std::cout << std::endl; return 0; }
Output:
Sigma is not a valid permutation. Tau is a valid permutation.
References:
SUBSET, a C++ library of combinatorial routines, http://www.csit.fsu.edu/~burkardt/cpp_src/subset/subset.htmlParameters
n the size of the p array p the actual array
Returns
- true, if p is a valid permutation, false otherwise
Authors
- Lucian Bentea (August 2005)
Source Code
Source code is available when you buy a Commercial licence.
Not a member, then Register with CodeCogs. Already a Member, then Login.