include algorithm, vector in C++11
int *arr = NULL;
arr = (int *) malloc(sizeof(int) * len);
std::vector<int> arrv(arr, arr+len);
int temp; cin >> temp;
arrv.push_back(temp); // add an element to the array
std::sort(arrv.begin(), arrv.end()); // MERGE SORT
arrv.clear(); // empty the array