error: no match for ‘operator<<’ (operand types are ‘std::basic_ostream<char>’ and ‘<unresolved overloaded function type>’)
error: no match for ‘operator<<’ (operand types are ‘std::basic_ostream<char>’ and ‘<unresolved overloaded function type>’)
我找不到错误 'operator <<'
不匹配的解决方案
下面是我产生错误的代码,
#include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int t;
std::cin >> t;
while(t--) {
long int i,n,count=0,idx,min=LONG_MAX;
cin >> n;
long int s[n];
for(i = 0; i < n; i++) {
cin >> s[i];
if(s[i] <= min) {
min = s[i];
idx = i;
}
}
cout << "count= " << count << " max= " << max << " idx= " << idx << "\n";
}
}
我收到类似
的错误
prog.cpp: In function ‘int main()’: prog.cpp:19:43: error: no match
for ‘operator<<’ (operand types are ‘std::basic_ostream<char>’ and
‘<unresolved overloaded function type>’)
cout<< "count= "<< count << " max= " << max << " idx= " << idx <<"\n";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
谁能帮我解决这个问题。
首先,max(第 19 行)未声明。
它给出此错误是因为它试图调用内置的 std::max(算法头文件)。
我猜你打错了它是最小值(在第 19 行)而不是最大值 :)。
我找不到错误 'operator <<'
不匹配的解决方案下面是我产生错误的代码,
#include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int t;
std::cin >> t;
while(t--) {
long int i,n,count=0,idx,min=LONG_MAX;
cin >> n;
long int s[n];
for(i = 0; i < n; i++) {
cin >> s[i];
if(s[i] <= min) {
min = s[i];
idx = i;
}
}
cout << "count= " << count << " max= " << max << " idx= " << idx << "\n";
}
}
我收到类似
的错误prog.cpp: In function ‘int main()’: prog.cpp:19:43: error: no match
for ‘operator<<’ (operand types are ‘std::basic_ostream<char>’ and
‘<unresolved overloaded function type>’)
cout<< "count= "<< count << " max= " << max << " idx= " << idx <<"\n";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
谁能帮我解决这个问题。
首先,max(第 19 行)未声明。 它给出此错误是因为它试图调用内置的 std::max(算法头文件)。
我猜你打错了它是最小值(在第 19 行)而不是最大值 :)。