Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- namespace {
- template<int mod3>
- void fizz()
- { /* do nothing */ }
- template<>
- void fizz<0>()
- {
- std::printf("Fizz");
- }
- template<int mod5>
- void buzz()
- { /* do nothing */ }
- template<>
- void buzz<0>()
- {
- std::printf("Buzz");
- }
- template<bool mod>
- void decimal(int i)
- {
- std::printf("%d", i);
- }
- template<>
- void decimal<false>(int)
- { /* do nothing */ }
- template<int i>
- void loop()
- {
- fizz<i%3>();
- buzz<i%5>();
- decimal<i%3 && i%5>(i);
- std::putchar('\n');
- loop<i+1>();
- }
- template<>
- void loop<101>()
- { /* end recursion */ }
- } // namespace
- int main()
- {
- loop<1>();
- }
Advertisement
Add Comment
Please, Sign In to add comment