...数组的元素最大值,在主调函数中用函名调用该函数与用函数指针调用该...
发布网友
发布时间:2024-10-19 08:56
我来回答
共1个回答
热心网友
时间:2024-11-11 05:50
#include <stdio.h>
#include <limits.h>
int max(int* a, int n)
{
int res = INT_MIN, i = 0;
for(; i < n; i++)
if (a[i] > res) res = a[i];
return res;
}
int main()
{
int a[] = { 8, 9, 10, 0, 1, 3, 4 };
int (*pf)(int *, int) = max;
printf("%d\n", pf(a, 7));
printf("%d\n", max(a, 7));
return 0;
}