Skip to content

Instantly share code, notes, and snippets.

@boronology
Created August 2, 2012 14:34
Show Gist options
  • Select an option

  • Save boronology/3237498 to your computer and use it in GitHub Desktop.

Select an option

Save boronology/3237498 to your computer and use it in GitHub Desktop.
FizzBuzz
#include <iostream>
#include <string>
std::string fizzbuzz = "FizzBuzz";
std::string fizz = "Fizz";
std::string buzz = "Buzz";
struct dummyint
{
dummyint(const int i);
int val;
}
;
dummyint::dummyint(const int i)
:val(i)
{
}
std::ostream& operator<<(std::ostream& os,dummyint i)
{
if(!(i.val%15))
{
return os << fizzbuzz;
}
else if(!(i.val%5))
{
return os << buzz;
}
else if(!(i.val%3))
{
return os << fizz;
}
else
{
return os << i.val;
}
}
int main(int argc, char *argv[])
{
for(int i=0;i<100;i++)
{
std::cout << dummyint(i) << std::endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment