Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/142.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 错误C2678:二进制'&燃气轮机&燃气轮机';:未找到接受类型为';的左操作数的运算符;std::istream'。如何为搜索索引提供输入?_C++_Arrays - Fatal编程技术网

C++ 错误C2678:二进制'&燃气轮机&燃气轮机';:未找到接受类型为';的左操作数的运算符;std::istream'。如何为搜索索引提供输入?

C++ 错误C2678:二进制'&燃气轮机&燃气轮机';:未找到接受类型为';的左操作数的运算符;std::istream'。如何为搜索索引提供输入?,c++,arrays,C++,Arrays,我的任务是硬编码一个整数数组,向用户显示该数组,然后要求用户输入一个要搜索的整数。我的问题是获取搜索数组的输入 #include <iostream> using namespace std; int main () { int intArray [17] = {7, 3, 32, 2, 55, 34, 6, 13,29,22, 11, 9, 1, 5,42,39, 8}; cout << "List = 7, 3, 32, 2, 55, 34, 6, 13,29

我的任务是硬编码一个整数数组,向用户显示该数组,然后要求用户输入一个要搜索的整数。我的问题是获取搜索数组的输入

#include <iostream>
using namespace std;

int main ()

{

int intArray [17] = {7, 3, 32, 2, 55, 34, 6, 13,29,22, 11, 9, 1, 5,42,39, 8};

cout << "List = 7, 3, 32, 2, 55, 34, 6, 13,29,22, 11, 9, 1, 5,42,39, 8 " << endl;

cout << "Enter an integer in the list to search for: " << endl;
cin >> intArray;

}
#包括
使用名称空间std;
int main()
{
int intArray[17]={7,3,32,2,55,34,6,13,29,22,11,9,1,5,42,39,8};

cout编译器告诉您没有支持该调用的函数

cin >> intArray;
查看代码中的前一行,无论如何,这不是您应该做的。您需要以下内容:

int numberToLookFor;
cin >> numberToLookFor;

然后在
intArray
中添加代码以查找
numberToLookFor
,您不能像R.Sahu描述的那样搜索数组

您可以在请求输入的循环中使用范围基

大概是这样的:

int value;
std::cin >> value;
for (int i : intarray)
{  
   if (i == value)
   std::cout << "Found";
}
int值;
标准:cin>>值;
用于(int i:intarray)
{  
if(i==值)

STD::试着创建一个新的变量来读取输入。不要把它读入同一个iTalay.I我会怎么做?我的C++技巧是非常基本的,我怎么去添加代码去寻找NtubToRooKOF?