Giter Club home page Giter Club logo

modern-cxx's People

Contributors

semenovf avatar

Watchers

 avatar  avatar

Forkers

andreyproger

modern-cxx's Issues

Определитель от Комулова

#pragma once

#include

template
constexpr int getElem(const std::array<std::array<int, N>, N>& matr, int i, int j)
{
return matr[i][j];
}

template
constexpr int det(const std::array<std::array<int, N>, N>& matr, const int rowNum, const int colNum, const bool columns[N])
{
if(rowNum >= N && colNum >= N)
return 1;

bool columns2[N] = {false};
for(int i = 0; i < N; i++)
    columns2[i] = columns[i];
int sum = 0;
int columnNum = 0;
for(int i = 0; i < N; i++)
{
    if(columns[i]==false)
        continue;

    int a = getElem<N>(matr, rowNum, i);
    if(columnNum%2 != 0)
        a=-a;
    columnNum++;

    columns2[i] = false;
    sum += a*det<N>(matr, rowNum+1, colNum+1, columns2);
    columns2[i] = true;
}
return sum;

}

template
constexpr int determinant(const std::array<std::array<int, N>, N>& matr)
{
if(N <= 1)
return matr[0][0];
bool columns[N] = {true};
for(int i = 0; i < N ;i++)
{
columns[i] = true;
}
return det(matr, 0, 0, columns);
}

Implementation task next_prime.h

#include <math.h>

typedef unsigned int PrimeNumType;

constexpr bool isPrime(PrimeNumType number)
{
for(int i = 2; i <= ceil(std::sqrt(number)); i++)
{
if(number % i == 0)
return false;
}
return true;
}

constexpr PrimeNumType nextPrime(PrimeNumType num)
{
do
{
num++;
}
while(isPrime(num)==false);
return num;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.