c++ - 为什么会出现 invalid operands 的问题?
天蓬老师
天蓬老师 2017-04-17 13:58:53
0
4
1315

代码运行的时候出现了 invalid operands of types 'int (int, int)' and 'int' to binary 'operator<< ' 的错误。
代码如下:

//把M个同样的苹果放在N个同样的盘子里,允许有盘子空着,一共有几种放法?
#include <iostream>

using namespace std;

int count(int m, int n)
{
    if (m <=1 || n <=0) return 1;
    if (m < n)
        return count(m, m);
    else
        return count(m, n-1)+count(m-n, n);
}

void prime()
{
    int apples, plates;
    cin >> apples >> plates;
    count << count(apples, plates);
}

在count<< count(apples, plates),即倒数第二行处提示错误,为什么会出现这种类型的错误呢?

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

全員に返信(4)
左手右手慢动作

cout << count(apples, plates);

いいねを押す +0
左手右手慢动作

count << count(apples, plates);
左边是函数<<右边是int类型

这也能行?

いいねを押す +0
迷茫

你先说说你这么用的理由

いいねを押す +0
小葫芦

不好意思,我把cout打成count了

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