A
A
Alexander Bagirov2015-03-26 17:33:48
C++ / C#
Alexander Bagirov, 2015-03-26 17:33:48

How to print the contents of a set in C++?

Hello!
I have created a set in C++. Can you please tell me how to display all its contents on the screen?
I remember that this can be done somehow through set.end (), but I can’t write it correctly.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Armenian Radio, 2015-03-26
@alexbagirov

for (const auto &i:myset)
{
   cout << i << endl;
}

for (std::set<что-то>::iterator i=myset.begin();i!=myset.end();++i)
{
   cout << (*i) << endl;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question