diff --git a/modules/03_functions/src/default_parameters.cpp b/modules/03_functions/src/default_parameters.cpp index 2c547d3..869ad59 100644 --- a/modules/03_functions/src/default_parameters.cpp +++ b/modules/03_functions/src/default_parameters.cpp @@ -1,9 +1,26 @@ #include "default_parameters.hpp" +#include +#include + namespace functions { -auto repeat(char ch, int count) -> std::string { (void)ch; (void)count; return {}; } -auto power(int base, int exponent) -> long long { (void)base; (void)exponent; return 0; } -auto clamp(int value, int min, int max) -> int { (void)value; (void)min; (void)max; return 0; } +auto repeat(const char ch, const int count) -> std::string { + std::ostringstream oss; + for (int i = 0; i < count; i++) { + oss << ch; + } + return oss.str(); +} + +auto power(const int base, const int exponent) -> long long { + return std::pow(base, exponent); +} + +auto clamp(const int value, const int min, const int max) -> int { + if (value < min) return min; + if (value > max) return max; + return value; +} } // namespace functions