Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <array>
- #include <numeric>
- #include <algorithm>
- #include <cmath>
- #include <cstring>
- template<int N>
- constexpr int determinant(const std::array<std::array<int, N>, N>& a) {
- int det = 0;
- std::array<int, N> perm;
- std::iota(perm.begin(), perm.end(), 0);
- int cnt = 0;
- do {
- for (int i = 0; i < N; ++i) {
- std::cout << i << " " << perm[i] << "\n";
- det += pow(-1, cnt) * a[i][perm[i]];
- }
- ++cnt;
- std::cout << "\n";
- } while (std::next_permutation(perm.begin(), perm.end()));
- return det;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement