Adding 2nd assignment - recursion
This commit is contained in:
33
Fundamental_Recursion/Utils.h
Normal file
33
Fundamental_Recursion/Utils.h
Normal file
@@ -0,0 +1,33 @@
|
||||
#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
|
||||
Reference in New Issue
Block a user