highAndLow
This commit is contained in:
15
main.cpp
Normal file
15
main.cpp
Normal file
@@ -0,0 +1,15 @@
|
||||
#include <sstream>
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
std::string highAndLow(const std::string& numbers){
|
||||
std::vector<int> nums;
|
||||
std::istringstream iss(numbers);
|
||||
int num;
|
||||
while(iss >> num) {
|
||||
nums.push_back(num);
|
||||
}
|
||||
auto min_max = std::minmax_element(nums.begin(), nums.end());
|
||||
return std::is_string(*min_max.second()) + " " + std::string(*min_max.first();)
|
||||
}
|
||||
Reference in New Issue
Block a user