gpt4 book ai didi

c++ - 为什么我的程序无法识别 C++ 循环内的 Cin?

转载 作者:行者123 更新时间:2023-11-27 22:36:53 25 4
gpt4 key购买 nike

所以我是 C++ 的 super 新手,我正在尝试从用户那里获取一些值(一堆数字),我想找到这些数字的平均中位数和众数。这就是我想要做的,但是 for 循环中的第二个 cin 得到错误

Error C2679 binary '>>': no operator found which takes a right-hand operand of type 'overloaded-function' (or there is no acceptable conversion)

#include<iostream>
#include<string>

using namespace std;

int main()
{
int mean, max, min, range = 0;
int numbers[100];
cout << "please enter the range " << endl;
cin >> range;
cout << "please enter the values" << endl;
for (int i = 1; i < range; i++)
{
cin >> numbers[i] >> endl;
}
return 0;
}

谢谢!

最佳答案

std::endl 不是您可以为其赋值的变量。所以 cin >> endl 无法工作。

关于c++ - 为什么我的程序无法识别 C++ 循环内的 Cin?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53198562/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com