33 lines
994 B
C++
33 lines
994 B
C++
#ifndef FUNDAMENTAL_RECURSION_UTILS_H
|
|
#define FUNDAMENTAL_RECURSION_UTILS_H
|
|
|
|
#include <string>
|
|
#include <chrono>
|
|
|
|
|
|
void printNaturalNumber(int n);
|
|
int calculateFactorial(int n);
|
|
int power(int base, int exp);
|
|
int fibonacci(int n);
|
|
int countOccurrences(const std::string& s, char c);
|
|
int findLargestElement(const int arr[], int size);
|
|
void traverseAsciiTable(char start, char end);
|
|
|
|
|
|
// Helpers partially generated by ChatGPT
|
|
void fillRandomArray(int arr[], int size, int minVal, int maxVal);
|
|
std::string makeRandomString(int len, char minChar, char maxChar);
|
|
int countOccurrences_index(const std::string& s, char c, int index);
|
|
|
|
template<typename F, typename... Args>
|
|
double time_ms(F&& f, Args&&... args)
|
|
{
|
|
auto t0 = std::chrono::high_resolution_clock::now();
|
|
(void)std::forward<F>(f)(std::forward<Args>(args)...);
|
|
auto t1 = std::chrono::high_resolution_clock::now();
|
|
return std::chrono::duration<double, std::milli>(t1 - t0).count();
|
|
}
|
|
|
|
|
|
|
|
#endif //FUNDAMENTAL_RECURSION_UTILS_H
|