xxxxxxxxxx
std::vector<int> v = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
v.erase(std::remove(v.begin(), v.end(), 5), v.end());
// v will be {0 1 2 3 4 6 7 8 9}
xxxxxxxxxx
// Delete is like 'free' in C.
// If you have a dynamic variable, you need to free its memory (delete it) using the delete keyword.
int arr = new int[7];
delete arr[];
xxxxxxxxxx
// Non Empty map example
// CPP program to illustrate
// Implementation of empty() function
#include <iostream>
#include <map>
using namespace std;
int main()
{
map<char, int> mymap;
mymap['a'] = 1;
mymap['b'] = 2;
if (mymap.empty()) {
cout << "True";
}
else {
cout << "False";
}
return 0;
}
xxxxxxxxxx
#include <iostream>
using namespace std;
int main() {
int length;
cin >> length;
int * arr = new int[length];
for (int i = 0; i < length; i++) {
arr[i] = (i + 1) * 10;
}
for (int i = 0; i < length; i++) {
cout << arr[i] << " " << endl;
}
delete[] arr;
return 0;
}