Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

how to change certain number from set c++

//My solution would be to delete the number you want to change from the set,
//and then inserting the one you wanted to change it to.

//first of all get the value that you want to erase.
int x = 5;

// now delete it from the set called "st" for example using 'find()' command.
st.erase(find(x));

// 'find()' command basically takes the value you pass it, and finds the 
// position of that value in the set.(it actually uses binary search in sets, so
// it works pretty quickly).

// now add changed value using 'insert()' command
x = 10;
st.insert(x);
 
PREVIOUS NEXT
Tagged: #change #number #set
ADD COMMENT
Topic
Name
6+6 =