gpt-3.5-turbo-0613· OpenAI
WildChat-4.8M (AI2)
main.cpp:13:18: error: no match for ‘operator>>’ (operand types are ‘std::istream’ {aka…
- User
main.cpp:13:18: error: no match for ‘operator>>’ (operand types are ‘std::istream’ {aka ‘std::basic_istream’} and ‘std::vector’) 13 | std::cin >> a; Сам код:
#include #include
int main() { int n; std::vector a; std::vector res(200000, 0); std::cin >> n;
for (int i=0; i < n; i++) { std::cin >> a; res[a] = i; } int mn = 1000000000, iMn = -1; for(int i=0; i < res.size(); i++) { if (res[i] < mn) { mn = res[i]; iMn = i; } } std::cout << iMn; return 0;}
- Assistant
The error is because you are trying to use the
operator>>on astd::vector<int>object, which is not defined. Theoperator>>is only defined for basic types likeint,float, etc.To fix the error, you need to read the elements of the vector one by one using a loop:
for (int i = 0; i < n; i++) { int x; std::cin >> x; a.push_back(x); res[x] = i; }
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.