codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
#include <iostream> using namespace std; template <int I, bool Fizz = !(I % 3), bool Buzz = !(I % 5)> struct number {}; template <int I> void fizzbuzz(number<I, false, false>){ cout << I << "\n"; } template <int I> void fizzbuzz(number<I, true, false>){ cout << "Fizz\n"; } template <int I> void fizzbuzz(number<I, false, true>){ cout << "Buzz\n"; } template <int I> void fizzbuzz(number<I, true, true>){ cout << "FizzBuzz\n"; } template <int I, int J> struct driver{ static void run(){ driver<I, I + (J-I)/2>::run(); fizzbuzz(number<I + (J-I)/2>()); driver<I + (J-I)/2+1, J>::run(); } }; template <int I> struct driver<I, I>{ static void run(){ } }; int main(void){ driver<1,100+1>::run(); }
Private
[
?
]
Run code