Question: Traversing a vector to find the max ( or min ) is common. Given a vector of integers, output the maximum integer found in the
Traversing a vector to find the max or min is common. Given a vector of integers, output the maximum integer found in the vector. If the input is the output is
Hints:
Declare a variable named maxitem to hold the max value seen so far. Update that value if you ever see a larger value.
Initialize that variable to any element's value, NOT to
main.cpp
#include
#include
using namespace std;
int main
int numItems;
vector listItems;
int currItem;
int i;
Get items
cin numItems;
for i ; i numItems; i
cin gg currItem;
listItems.pushbackcurrItem;
Type your code here
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
