c++ - int类型的实参和int*类型的形参不兼容
阿神
阿神 2017-04-17 13:07:02
0
3
1482
#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;
}
阿神
阿神

闭关修行中......

reply all(3)
小葫芦

The Max function call is wrong, Max(ar), not Max(ar[20])

刘奇

int Max(int arr[])

cout << "The maximum number is:" << Max(ar);

洪涛

Okay, I've found the error.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!