Solved: 09 - Default Parameters
This commit is contained in:
@@ -1,9 +1,26 @@
|
||||
#include "default_parameters.hpp"
|
||||
|
||||
#include <cmath>
|
||||
#include <sstream>
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user