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

闭关修行中......

全員に返信(3)
小葫芦

Max函数调用错了,Max(ar),不是Max(ar[20])

いいねを押す +0
刘奇

int Max(int arr[])

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

いいねを押す +0
洪涛

好了,我已经找出错误了。

いいねを押す +0
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート
私たちについて 免責事項 Sitemap
PHP中国語ウェブサイト:福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!