这是正确代码,格式请自行调整
int getMax(int a, int b){return a > b ? a : b;} int getMax(int *arr, int count){int max = arr[0];for (int i = 1; i < count; i++){if (max<arr[i]){max = arr[i];}}return max;}int main(){int numArr[3] = { 3, 8, 6 };cout << getMax(numArr[0], numArr[2]) << endl;cout << getMax(numArr, 3) << endl;return 0;}