+ 1

c++ Error

What is a wrong here i got compiler error ? # include <bits/stdc++.h> using namespace std; int main() { freopen(R"(F:\Contest - 13 - 3\2\in.txt.txt)", "r", stdin); int x; vector<pair<int, int>> v; while (cin >> x) { auto it = find(v.begin()->first, v.end()->first, x); if (it != v.end()->first) v[it].second++; else v.emplace_back(x, 1); } for (auto it : v) cout << it.first << " " << it.second << endl; }

16th Mar 2020, 2:44 PM
Youseef Moemen
Youseef Moemen - avatar
5 Antworten
+ 2
Even if you change the way you call `find`, you are still not likely to find anything. Your vector is empty. Maybe take a look at std::map? you mentioned "key".
16th Mar 2020, 4:12 PM
Ipang
+ 1
Is that the whole code? Can you describe what you wanted or expected to do with this code?
16th Mar 2020, 3:19 PM
Ipang
0
What should I do if i want to find the key only from pair
16th Mar 2020, 3:40 PM
Youseef Moemen
Youseef Moemen - avatar