- Challenge Activity 301722 2037154 Xpolomy7 Jump To Level 1 Integers Are Read From Input And Stored Into A Vector Until 0 1 (19.07 KiB) Viewed 23 times
CHALLENGE ACTIVITY 301722.2037154.xpołomy7 Jump to level 1 Integers are read from input and stored into a vector until 0
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
CHALLENGE ACTIVITY 301722.2037154.xpołomy7 Jump to level 1 Integers are read from input and stored into a vector until 0
CHALLENGE ACTIVITY 301722.2037154.xpołomy7 Jump to level 1 Integers are read from input and stored into a vector until 0 is read. Output the first n elements in the vector, where n is specified by the vector's last element. End each number with a newline. Ex: If the input is 9 8 17 3 0, the vector's last element is 3. Thus, the output is: 9 8 17 Note: 5.5.1: Making and using vectors. • The input has at least three integers, and the vector's last element is always less than the vector's size. A vector's back() function returns the vector's last element. Ex: myVector.back() 3 using namespace std; 4 5 int main() { 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 } int i; int n; vector (int number Vector; int value; cin >> value; while (value != 0) { number vector.push_back (value); cin >> value; return 0; D-DDD*