Search
 
SCRIPT & CODE EXAMPLE
 

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);
Comment

PREVIOUS NEXT
Code Example
Cpp :: how to output to console c++ 
Cpp :: how to sort a string in c++ 
Cpp :: add on screen debug message ue4 
Cpp :: c++ run loop for 5 seconds 
Cpp :: reverse an array using pointers in c++ 
Cpp :: c++ stream string into fiel 
Cpp :: cout hello world 
Cpp :: how can I replace a pattern from string in c++ 
Cpp :: taking input from user in array in c++ 
Cpp :: how to convert a string to a double c++ 
Cpp :: char vector to string c++ 
Cpp :: input a string in c++ 
Cpp :: is C++ useful in 2021 
Cpp :: point is on line 
Cpp :: how to write a hello world program in c++ 
Cpp :: c++ show current time 
Cpp :: maximum value in map in c++ 
Cpp :: how to get a letter from the user c++ string 
Cpp :: c++ code for insertion sort 
Cpp :: how to traverse a linked list in c++ 
Cpp :: c++ loop through string 
Cpp :: syntax c++ 
Cpp :: c++ string comparison 
Cpp :: 2d vector c++ size 
Cpp :: c++ check if vector is sorted 
Cpp :: mkdir c++ 
Cpp :: cpp multidimensional vector 
Cpp :: overload stream insert cpp 
Cpp :: how to add an element to std::map 
Cpp :: divide and conquer based algorithm to find maximum and minimum of an array 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =