diff options
| author | Richard Qin <richard.qin.001@gmail.com> | 2026-09-15 08:16:43 +0800 |
|---|---|---|
| committer | Richard Qin <richard.qin.001@gmail.com> | 2026-09-15 08:16:43 +0800 |
| commit | 4022e5c95210631e4aceb08eaf9d9071aa5aefc4 (patch) | |
| tree | a5922559836e45fb3459a3d070367912e1035b1a /tests/performance/08_floyd.sy | |
| download | rcc-master.tar.gz rcc-master.tar.xz | |
Diffstat (limited to 'tests/performance/08_floyd.sy')
| -rw-r--r-- | tests/performance/08_floyd.sy | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/performance/08_floyd.sy b/tests/performance/08_floyd.sy new file mode 100644 index 0000000..30db367 --- /dev/null +++ b/tests/performance/08_floyd.sy @@ -0,0 +1,45 @@ +const int N = 1024; +int dist[N][N]; + +int main() { + int n = getint(); + int i, j; + i = 0; + while (i < n) { + j = 0; + while (j < n) { + dist[i][j] = getint(); + j = j + 1; + } + i = i + 1; + } + + int k = 0; + while (k < n) { + i = 0; + while (i < n) { + j = 0; + while (j < n) { + if (dist[i][k] + dist[k][j] < dist[i][j]) { + dist[i][j] = dist[i][k] + dist[k][j]; + } + j = j + 1; + } + i = i + 1; + } + k = k + 1; + } + + + i = 0; + while (i < n) { + j = 0; + while (j < n) { + putint(dist[i][j]); + putch(32); + j = j + 1; + } + i = i + 1; + } + return 0; +}
\ No newline at end of file |
