Answer:
#include <iostream>
#include <vector>
using namespace std;
/* Define your function here */
vector<int> GetUserValues(vector<int>& userValues, int numValues) {
int tmp = 0;
vector<int> newVec;
for(int i = 0; i < numValues; i++) {
cin >> tmp;
newVec.push_back(tmp);
}
return newVec;
}
void OutputIntsLessThanOrEqualToThreshold(vector<int> userValues, int upperThreshold) {
for (int i = 0; i < userValues.size(); ++i) {
if(userValues.at(i) < upperThreshold) {
cout << userValues.at(i) << " ";
}
}
cout << endl;
}
int main() {
vector<int> userValues;
int upperThreshold;
int numValues;
cin >> numValues;
userValues = GetUserValues(userValues, numValues);
cin >> upperThreshold;
OutputIntsLessThanOrEqualToThreshold(userValues, upperThreshold);
return 0;
}
Step-by-step explanation:
Perhaps their is a better way to code this, but I couldn't figure out what to do with the pointer in the first function.