set iterator

#include <iostream>
#include <set>

int main() {
    std::set<int> mySet = {1, 2, 3, 4, 5};

    // Declaring an iterator for the set
    std::set<int>::iterator it;

    // Using iterator to traverse the set and print its elements
    std::cout << "Set elements: ";
    for (it = mySet.begin(); it != mySet.end(); ++it) {
        std::cout << *it << " ";
    }

    // Finding an element in the set using iterator
    int elementToFind = 3;
    it = mySet.find(elementToFind);

    // Checking if the element was found and printing the result
    if (it != mySet.end()) {
        std::cout << "\nElement " << elementToFind << " found in the set." << std::endl;
    } else {
        std::cout << "\nElement " << elementToFind << " not found in the set." << std::endl;
    }

    return 0;
}