Untitled

 avatar
unknown
plain_text
a year ago
654 B
8
Indexable
#include <iostream>
#include <set>

int main() {
    // Create a set of integers
    std::set<int> mySet;

    // Insert elements into the set
    mySet.insert(5);
    mySet.insert(2);
    mySet.insert(8);

    // Display the elements of the set
    std::cout << "Set after insertion: ";
    for (int elem : mySet) {
        std::cout << elem << " ";
    }
    std::cout << std::endl;

    // Delete an element from the set
    mySet.erase(2);

    // Display the elements of the set after deletion
    std::cout << "Set after deletion: ";
    for (int elem : mySet) {
        std::cout << elem << " ";
    }
    std::cout << std::endl;

    return 0;
}
Editor is loading...
Leave a Comment