Files
cpp-course/modules/03_functions/src/default_parameters.cpp
T

27 lines
554 B
C++
Raw Normal View History

2026-08-11 17:40:36 +03:00
#include "default_parameters.hpp"
2026-08-12 15:57:54 +03:00
#include <cmath>
#include <sstream>
2026-08-11 17:40:36 +03:00
namespace functions {
2026-08-12 15:57:54 +03:00
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;
}
2026-08-11 17:40:36 +03:00
} // namespace functions