Integers are read from input and stored into a vector until 0 is read. Output the elements in the vector, replacing any

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Integers are read from input and stored into a vector until 0 is read. Output the elements in the vector, replacing any

Post by answerhappygod »

Integers Are Read From Input And Stored Into A Vector Until 0 Is Read Output The Elements In The Vector Replacing Any 1
Integers Are Read From Input And Stored Into A Vector Until 0 Is Read Output The Elements In The Vector Replacing Any 1 (76.11 KiB) Viewed 24 times
#include <iostream>#include <vector>using namespace std;
int main() { int i; vector<int> intVector; int value;
cin >> value; while (value != 0) { intVector.push_back(value); cin >> value; }
z /* Your code goes here */
return 0;}
Integers are read from input and stored into a vector until 0 is read. Output the elements in the vector, replacing any elements greater than the vector's last element with "SKIP". End each number with a newline. Ex: If the input is 5−3−1540, the vector's last element is 4 . Thus, the output is: SKIP −3 −15 4 Note: A vector's back() function returns the vector's last element. Ex: myVector.back0 1 #include 2 #include 3 using namespace std; 4 5 int main() \{ 6 int i; 7 vector < int > intVector; 8 int value; 10 cin ≫ value; 11 while (value !=0){ 12 intVector,push_back(value); 13 cin > value; 143
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply