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/functional/42_index_func_ret.sy | |
| download | rcc-master.tar.gz rcc-master.tar.xz | |
Diffstat (limited to 'tests/functional/42_index_func_ret.sy')
| -rw-r--r-- | tests/functional/42_index_func_ret.sy | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/functional/42_index_func_ret.sy b/tests/functional/42_index_func_ret.sy new file mode 100644 index 0000000..136d6eb --- /dev/null +++ b/tests/functional/42_index_func_ret.sy @@ -0,0 +1,24 @@ +// Use return value of a function as array's index +int _getMaxOfAll(int result[], int size) { + int maxNum; + maxNum = -999999; + size = size - 1; + while(size > -1) { + if (result[size] > maxNum) { + maxNum = result[size]; + } + size = size - 1; + } + return maxNum; +} + +int main() { + int result[3]; + result[0] = -2; + result[1] = 2; + result[2] = -7; + int x; + x = result[_getMaxOfAll(result, 3)]; + putint(x); + return 0; +} |
