mirror of
https://github.com/TheAlgorithms/C
synced 2024-11-22 13:31:21 +03:00
aef9d8d53f
* file names modified * files name modified * file names modified * updating DIRECTORY.md Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
61 lines
2.1 KiB
C
61 lines
2.1 KiB
C
#include <stdbool.h>
|
|
#include <stdio.h>
|
|
|
|
#define NODES 4
|
|
|
|
int digraph[NODES][NODES] = {
|
|
{0, 1, 1, 1}, {1, 0, 1, 0}, {0, 1, 0, 0}, {0, 0, 0, 0}};
|
|
int tc[NODES][NODES];
|
|
|
|
void warshall()
|
|
{
|
|
int i, s, t;
|
|
for (s = 0; s < NODES; s++)
|
|
for (t = 0; t < NODES; t++) tc[s][t] = digraph[s][t];
|
|
|
|
for (i = 0; i < NODES; i++)
|
|
for (s = 0; s < NODES; s++)
|
|
for (t = 0; t < NODES; t++)
|
|
if (tc[s][i] && tc[i][t])
|
|
tc[s][t] = 1;
|
|
}
|
|
|
|
int main(void)
|
|
{
|
|
warshall();
|
|
int i, j;
|
|
for (i = 0; i < NODES; i++)
|
|
{
|
|
for (j = 0; j < NODES; j++)
|
|
{
|
|
printf("%d ", tc[i][j]);
|
|
}
|
|
putchar('\n');
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
// By
|
|
// .----------------. .----------------. .----------------.
|
|
// .-----------------. .----------------. .----------------.
|
|
// | .--------------. || .--------------. || .--------------. ||
|
|
// .--------------. | | .--------------. || .--------------. | | | _________ |
|
|
// || | _____ _____ | || | __ | || | ____ _____ | | | | ____ ____
|
|
// | || | ____ | | | | | _ _ | | || ||_ _||_ _|| || | / \
|
|
// | || ||_ \|_ _| | | | | |_ || _| | || | .' `. | | | | |_/ | |
|
|
// \_| | || | | | | | | || | / /\ \ | || | | \ | | | | | | |
|
|
// |__| | | || | / .--. \ | | | | | | | || | | ' ' | | || |
|
|
// / ____ \ | || | | |\ \| | | | | | | __ | | || | | | | | | |
|
|
// | | _| |_ | || | \ `--' / | || | _/ / \ \_ | || | _| |_\ |_
|
|
// | | | | _| | | |_ | || | \ `--' / | | | | |_____| | || | `.__.'
|
|
// | || ||____| |____|| || ||_____|\____| | | | | |____||____| | || | `.____.'
|
|
// | | | | | || | | || | | || | | | | |
|
|
// | || | | | | '--------------' || '--------------' ||
|
|
// '--------------' || '--------------' | | '--------------' || '--------------'
|
|
// |
|
|
// '----------------' '----------------' '----------------'
|
|
// '----------------' '----------------' '----------------'
|
|
|
|
// Email : z5261243@unsw.edu.au
|
|
// hhoanhtuann@gmail.com
|