2020-01-17 12:10:31 +03:00
|
|
|
#include <stdbool.h>
|
2020-05-29 23:23:24 +03:00
|
|
|
#include <stdio.h>
|
2020-01-17 12:10:31 +03:00
|
|
|
|
|
|
|
#define NODES 4
|
|
|
|
|
2020-05-29 23:23:24 +03:00
|
|
|
int digraph[NODES][NODES] = {
|
|
|
|
{0, 1, 1, 1}, {1, 0, 1, 0}, {0, 1, 0, 0}, {0, 0, 0, 0}};
|
2020-01-17 12:10:31 +03:00
|
|
|
int tc[NODES][NODES];
|
|
|
|
|
2020-05-29 23:23:24 +03:00
|
|
|
void warshall()
|
|
|
|
{
|
|
|
|
int i, s, t;
|
|
|
|
for (s = 0; s < NODES; s++)
|
2020-06-28 18:25:37 +03:00
|
|
|
for (t = 0; t < NODES; t++) tc[s][t] = digraph[s][t];
|
2020-01-17 12:10:31 +03:00
|
|
|
|
2020-05-29 23:23:24 +03:00
|
|
|
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;
|
2020-01-17 12:10:31 +03:00
|
|
|
}
|
|
|
|
|
2020-05-29 23:23:24 +03:00
|
|
|
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;
|
2020-01-17 12:10:31 +03:00
|
|
|
}
|
|
|
|
|
2020-05-29 23:23:24 +03:00
|
|
|
// By
|
|
|
|
// .----------------. .----------------. .----------------.
|
|
|
|
// .-----------------. .----------------. .----------------.
|
|
|
|
// | .--------------. || .--------------. || .--------------. ||
|
|
|
|
// .--------------. | | .--------------. || .--------------. | | | _________ |
|
|
|
|
// || | _____ _____ | || | __ | || | ____ _____ | | | | ____ ____
|
|
|
|
// | || | ____ | | | | | _ _ | | || ||_ _||_ _|| || | / \
|
|
|
|
// | || ||_ \|_ _| | | | | |_ || _| | || | .' `. | | | | |_/ | |
|
|
|
|
// \_| | || | | | | | | || | / /\ \ | || | | \ | | | | | | |
|
|
|
|
// |__| | | || | / .--. \ | | | | | | | || | | ' ' | | || |
|
|
|
|
// / ____ \ | || | | |\ \| | | | | | | __ | | || | | | | | | |
|
|
|
|
// | | _| |_ | || | \ `--' / | || | _/ / \ \_ | || | _| |_\ |_
|
|
|
|
// | | | | _| | | |_ | || | \ `--' / | | | | |_____| | || | `.__.'
|
|
|
|
// | || ||____| |____|| || ||_____|\____| | | | | |____||____| | || | `.____.'
|
|
|
|
// | | | | | || | | || | | || | | | | |
|
|
|
|
// | || | | | | '--------------' || '--------------' ||
|
|
|
|
// '--------------' || '--------------' | | '--------------' || '--------------'
|
|
|
|
// |
|
|
|
|
// '----------------' '----------------' '----------------'
|
|
|
|
// '----------------' '----------------' '----------------'
|
|
|
|
|
2020-01-17 12:10:31 +03:00
|
|
|
// Email : z5261243@unsw.edu.au
|
|
|
|
// hhoanhtuann@gmail.com
|