mirror of
https://hub.njuu.cf/TheAlgorithms/C-Plus-Plus.git
synced 2023-10-11 13:05:55 +08:00
67e26cfbae
* feat: Add ncr mod p code (#1323) * Update math/ncr_modulo_p.cpp Co-authored-by: David Leal <halfpacho@gmail.com> * Added all functions inside a class + added more asserts * updating DIRECTORY.md * clang-format and clang-tidy fixes forf6df24a5
* Replace int64_t to uint64_t + add namespace + detailed documentation * clang-format and clang-tidy fixes fore09a0579
* Add extra namespace + add const& in function arguments * clang-format and clang-tidy fixes for8111f881
* Update ncr_modulo_p.cpp * clang-format and clang-tidy fixes for2ad2f721
* Update math/ncr_modulo_p.cpp Co-authored-by: David Leal <halfpacho@gmail.com> * Update math/ncr_modulo_p.cpp Co-authored-by: David Leal <halfpacho@gmail.com> * Update math/ncr_modulo_p.cpp Co-authored-by: David Leal <halfpacho@gmail.com> * clang-format and clang-tidy fixes for5b69ba5c
* updating DIRECTORY.md * clang-format and clang-tidy fixes fora8401d4b
Co-authored-by: David Leal <halfpacho@gmail.com> Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
32 lines
1.0 KiB
C++
32 lines
1.0 KiB
C++
#include <array>
|
|
#include <iostream>
|
|
|
|
void findMinimumEdge(int INFINITY, std::array<std::array<int, 6>, 6> graph) {
|
|
for (int i = 0; i < graph.size(); i++) {
|
|
int min = INFINITY;
|
|
int minIndex = 0;
|
|
for (int j = 0; j < graph.size(); j++) {
|
|
if (graph[i][j] != 0 && graph[i][j] < min) {
|
|
min = graph[i][j];
|
|
minIndex = j;
|
|
}
|
|
}
|
|
std::cout << i << " - " << minIndex << "\t" << graph[i][minIndex]
|
|
<< std::endl;
|
|
}
|
|
}
|
|
|
|
int main() {
|
|
constexpr int INFINITY = 99999;
|
|
std::array<std::array<int, 6>, 6> graph{
|
|
0, 4, 1, 4, INFINITY, INFINITY,
|
|
4, 0, 3, 8, 3, INFINITY,
|
|
1, 3, 0, INFINITY, 1, INFINITY,
|
|
4, 8, INFINITY, 0, 5, 7,
|
|
INFINITY, 3, 1, 5, 0, INFINITY,
|
|
INFINITY, INFINITY, INFINITY, 7, INFINITY, 0};
|
|
|
|
findMinimumEdge(INFINITY, graph);
|
|
return 0;
|
|
}
|