#include // contains both set and multiset #include // provides pair #include using namespace std; void main() { multiset ms; // use default constructor to create an empty multiset int i; cout << "Enter integers separated by whitespace, end with -1:" << endl; do { cin >> i; if (i == -1) { break; } ms.insert(i); } while (true); cout << "A total of " << ms.size() << " integer(s) were entered." << endl; set s; // construct empty set cout << "Enter query values, end with -1: " << endl; do { cin >> i; if (i == -1) { break; } cout << "The sequence contains " << ms.count(i) << " occurrences of " << i << endl; s.insert(i); } while (true); cout << "You queried on " << s.size() << " unique integer(s)." << endl; }