为什么我的程序无法识别 C++ 循环内的 Cin?
Why doesn't my program recognize Cin inside a loop in C++?
所以我是 C++ 的超级新手,我正在尝试从用户那里获取一些值(一堆数字),我想找到这些数字的平均中位数和众数。这就是我想要做的,但是 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
无法工作。
std::endl
是仅输出 I/O 操纵器。将您的流输入行更改为 cin >> numbers[i];
所以我是 C++ 的超级新手,我正在尝试从用户那里获取一些值(一堆数字),我想找到这些数字的平均中位数和众数。这就是我想要做的,但是 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
无法工作。
std::endl
是仅输出 I/O 操纵器。将您的流输入行更改为 cin >> numbers[i];