Using only these simpler vector methods Create a vector of at least 10 integers. Cout the vector with spaces in between the integers. Cout the vector backward. Using loops that traverse the elements, create a new vector with the elements arranged from high to low. Cout the new vector.
Using C++
- Using only these simpler vector methods
- Create a vector of at least 10 integers.
- Cout the vector with spaces in between the integers.
- Cout the vector backward.
- Using loops that traverse the elements, create a new vector with the elements arranged from high to low.
- Cout the new vector.
- Do not use iterators for this exercise, or any other advanced methods--only the ones listed below.
Hint: Use multiple
vector<int> grades1 = {45, 67, 88, 45, 23};
vector<int> grades2 = grades1;
- May Only Use These Vector Methods:
size() // Returns the number of elements
empty() // Returns a boolean True if the vector is empty
push_back(element) // Adds an element to the back of the vector
pop_back() // Removes the element at the back of the vector
front() // Returns the element at the front of the vector
back() // Returns the element at the back of the vector
at(index) // Returns the element at the index position
- EXTRA CREDIT worth up to 100 extra pts (and a great way to study for the final):
- Add the ability for a user to input a set of grades into a vector.
- Use the data integrity techniques we learned before so that only integers (and only integers between 0 and 100) are used.
- Cout the vector onto the screen with grades separated by spaces and starting with, "Original user vector: "
- Write the grades from the vector to a file using tabs ( '\t' ) between the numbers.
- Read, the grades from the file into a new vector.
- Cout the new file-read vector onto the screen with grades separated by spaces and starting with, "Grades from file vector: "
- Create a new vector with the grades sorted from low to high (NOT High to Low).
- Cout the new sorted vector onto the screen with grades separated by spaces and starting with, "Grades sorted vector: "
- Just add your extra credit work to the Assignment 11 program. So only one file will be submitted--not a separate extra credit file.
- Done!
- Add the ability for a user to input a set of grades into a vector.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps