#include<iostream>
using namespace std;
int ar[20];
int main()
{
cout << "Please input 20 number to ar.";
for (int i = 0; i < 20; ++i)
{
cin >> ar[i];
}
cout << "The maximum number is:" << Max(ar[20]);
return 0;
}
//Function for Maximum.
int Max(int arr[20])
{
int max = arr[0];
for (int j = 1; j < 20; ++j)
{
if (arr[j] > max)
max = arr[j];
}
return max;
}
Max函数调用错了,Max(ar),不是Max(ar[20])
int Max(int arr[])
cout << "The maximum number is:" << Max(ar);
好了,我已经找出错误了。