How to find element in set with C++

1 Answer

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

using std::cout;
using std::endl;
using std::string;
using std::set;

int main()
{
	set<string> st{ "c", "c++", "java", "php" };

	set<string>::iterator p = st.begin();

	p = st.find("c++");
	if (p != st.end())
		cout << "Found" << endl;
	else
		cout << "Not Found" << endl;

	return 0;
}


/*
run:

Found

*/

 



answered Apr 23, 2018 by avibootz

Related questions

1 answer 98 views
1 answer 65 views
1 answer 106 views
106 views asked Oct 20, 2022 by avibootz
1 answer 130 views
2 answers 124 views
124 views asked Oct 21, 2022 by avibootz
...