From 1e0a87a5ca7bfd173f2a67261b69d78d0a5d21cb Mon Sep 17 00:00:00 2001 From: Dmitriy Gorshenin Date: Tue, 30 May 2023 12:26:36 +0300 Subject: [PATCH] highAndLow --- main.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 main.cpp diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..e415d1d --- /dev/null +++ b/main.cpp @@ -0,0 +1,15 @@ +#include +#include +#include +#include + +std::string highAndLow(const std::string& numbers){ + std::vector 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();) +}