blob: 136d6eb8523ee866e129c97f8f2b6ebee7558226 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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;
}
|