#include // For input/output operations #include // For setw formatting #include // For the vector container #include // For sort() #include // For EXIT_SUCCESS using namespace std; int main() { // Create a vector holding the prices of 4 expensive diamond gems vector f { 5000, // Blue Diamond 7500, // Black Diamond 6200, // Pink Diamond 8900 // Imperial Diamond }; // Store the number of elements currently in the vector vector::size_type n { f.size() }; // Display the gems the vector was born with cout << "The vector was born holding these " << n << " diamond prices:\n"; // Loop through the vector and print each price for (int i {0}; i < n; ++i) { cout << i << " $" << setw(3) << f[i] << "\n"; } cout << "\n"; // Add a 5th diamond gem using push_back() f.push_back(9600); // Add a new expensive diamond // Update the size after adding the new gem n = f.size(); // Display the updated vector cout << "Now the vector holds these " << n << " diamond prices:\n"; for (int i {0}; i < n; ++i) { cout << i << " $" << setw(3) << f[i] << "\n"; } // Display the sorted vector cout << "Diamond prices sorted (high → low):\n"; for (int i {0}; i < n; ++i) { cout << i << " $" << setw(3) << f[i] << "\n"; } return EXIT_SUCCESS; }