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

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,895 questions

51,826 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 155 views
1 answer 183 views
1 answer 138 views
3 answers 290 views
1 answer 164 views
1 answer 142 views
...