5 ms·
These are fun. In C++, make the compiler do your recursion: #include <iostream> template <int N> void pr(const std::string &msg) { std::cout <<
by sad 14y ago
These are fun.
In C++, make the compiler do your recursion:
#include <iostream>
template <int N>
void pr(const std::string &msg)
{
std::cout << msg << std::endl;
pr<N-1>(msg);
}
template <>
void pr<0>(const std::string &msg)
{
}
int main(int argc, char *argv[])
{
pr<100>("Hello World");
return 0;
}