#includeint main() { std::vector v1; // an empty vector std::vector v2(10); // a vector with 10 elements initialized to 0.0 std::vector v3 = {1.0, 2.0, 3.0}; // a vector initialized with 3 elements return 0; }
#includeint main() { std::vector v = {1.0, 2.0, 3.0}; v.push_back(4.0); // add 4.0 to the end of the vector v.insert(v.begin() + 1, 5.0); // insert 5.0 at index 1 return 0; }
#includeThe VectorDouble class is part of the CPP Standard Library, which is already included in the C++ programming language and does not require any additional package libraries.#include bool compare(double a, double b) { return a < b; } int main() { std::vector v = {3.0, 2.0, 1.0}; std::sort(v.begin(), v.end(), compare); // sort the vector in ascending order return 0; }