Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Integer numValues is read from input. Given the integer vector hourlyPrices with the size of numValues, assign numMatches with the number of integers in userValues

Integer numValues is read from input. Given the integer vector hourlyPrices with the size of numValues, assign numMatches with the number of integers in userValues that are equal to 5.

Ex: If the input is

5

74 5 5 5 135

then the output is:

matchValue: 5, numMatches: 3 

#include #include using namespace std;

int main() { vector hourlyPrices; unsigned int i; int numValues; int numMatches;

cin >> numValues; // Creates a vector of size numValues and initialize all values to 0 hourlyPrices.resize(numValues);

for (i = 0; i < hourlyPrices.size(); ++i) { cin >> hourlyPrices.at(i); } /* Your code goes here */ cout << "matchValue: 5, " << "numMatches: " << numMatches << endl; return 0; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started