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/15_transpose.sy | |
| download | rcc-4022e5c95210631e4aceb08eaf9d9071aa5aefc4.tar.gz rcc-4022e5c95210631e4aceb08eaf9d9071aa5aefc4.tar.xz | |
Diffstat (limited to 'tests/performance/15_transpose.sy')
| -rw-r--r-- | tests/performance/15_transpose.sy | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/performance/15_transpose.sy b/tests/performance/15_transpose.sy new file mode 100644 index 0000000..14c6782 --- /dev/null +++ b/tests/performance/15_transpose.sy @@ -0,0 +1,55 @@ +const int N = 1024; +void transpose(int n, int A[][N], int B[][N]) { + int i = 0; + + i = 0; + while (i < n) { + int j = 0; + while (j < n) { + B[i][j] = A[j][i]; + j = j + 1; + } + i = i + 1; + } +} + +int A[N][N]; +int B[N][N]; + +int main() { + int n = getint(); + int i, j; + + i = 0; + j = 0; + while (i < n){ + j = 0; + while (j < n){ + A[i][j] = getint(); + j = j + 1; + } + i = i + 1; + } + + starttime(); + i = 0; + while (i < 500) { + transpose(n, A, B); + transpose(n, B, A); + i = i + 1; + } + int ans = 0; + i = 0; + while (i < n){ + j = 0; + while (j < n){ + ans = ans + B[i][j]; + j = j + 1; + } + i = i + 1; + } + stoptime(); + putint(ans); + putch(10); + return 0; +}
\ No newline at end of file |
