Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Semrush - keyword research tool

Turn ChatGPT, Claude, Gemini, And CoPilot Into Your Personal Assistant, Business Coach, Content Creator, And More

AFFILIATE MARKETING Your all-in-one performance engine Manage affiliates, creators, and customer referrals in one unified platform—turning every partnership into measurable growth
Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

42,709 questions

55,473 answers

573 users

How to create and use unordered_multiset container for strings in C++

2 Answers

0 votes
#include <iostream>
#include <unordered_set>
#include <string>

int main()
{
	std::unordered_multiset<std::string> ulist { "c++", "c", "c#" };

	for (const auto& elem : ulist) {
		std::cout << elem << "  ";
	}
	std::cout << std::endl;

	ulist.insert({ "python", "php", "java" });

	for (const auto& elem : ulist) {
		std::cout << elem << "  ";
	}
	std::cout << std::endl;

	return 0;
}

/*
run:

c++  c  c#
c++  c  c#  php  python  java

*/

 



answered Dec 27, 2017 by avibootz
0 votes
#include <iostream>
#include <unordered_set>

using namespace std;

int main()
{
	std::unordered_multiset<int> umlist;

	umlist.insert({ 1, 2, 16, 19, 26, 28, 30 });

	for (auto elem : umlist) {
		std::cout << elem << ' ';
	}
	std::cout << std::endl;

	umlist.insert(27);

	for (auto elem : umlist) {
		std::cout << elem << ' ';
	}
	std::cout << std::endl;

	return 0;
}

/*
run:

1 26 2 16 19 28 30
1 26 2 16 27 19 28 30

*/

 



answered Dec 29, 2017 by avibootz

Related questions

1 answer 206 views
1 answer 232 views
1 answer 188 views
3 answers 375 views
1 answer 228 views
1 answer 200 views
...