Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- void GetUserValues(vector<int>& userValues, const int numValues) {
- for (int i = 0; i < numValues; i++) {
- cin >> userValues[i];
- }
- }
- void IntsLessThanOrEqualToThreshold(vector<int> userValues, const int upperThreshold, vector<int>& resValues) {
- int j = 0;
- for (int i = 0; i < userValues.size(); i++) {
- if (userValues[i] <= upperThreshold) {
- resValues.push_back(userValues[i]);
- }
- }
- }
- int main() {
- int size,i,threshold;
- cin >> size;
- vector<int> userValues(size);
- vector<int> resValues;
- GetUserValues(userValues, size);
- cin >> threshold;
- IntsLessThanOrEqualToThreshold(userValues, threshold, resValues);
- for (i = 0; i < resValues.size(); i++) {
- cout <<resValues[i] << " ";
- }
- cout<<endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment