C++ set Data Manipulation Question

Introduction

Write a program that defines a set and inserts two new values using the set's.insert() member function.

Then, delete one arbitrary value from a set using the set's.erase() member function.

Print out the set content afterward.

You can use the following code structure:

#include <iostream> 

int main() 
{ 

} 


#include <iostream> 
#include <set> 

int main() 
{ 
    std::set<int> myset = { -10, 1, 3, 5, 6, 9, 15 }; 
    myset.insert(-5); // inserts a value of -5 
    myset.insert(30); // inserts a value of 30 

    myset.erase(6); // deletes a value of 6 
    for (auto el : myset) 
    { 
        std::cout << el << '\n'; 
    } 
} 



PreviousNext

Related