+ 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; }
5 Réponses
+ 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".
+ 1
Is that the whole code?
Can you describe what you wanted or expected to do with this code?
0
What should I do if i want to find the key only from pair