Skip to content

Instantly share code, notes, and snippets.

@badboy
Created July 2, 2021 09:26
Show Gist options
  • Save badboy/21484fbf43808fffe16fe3d7f7358ad0 to your computer and use it in GitHub Desktop.
Save badboy/21484fbf43808fffe16fe3d7f7358ad0 to your computer and use it in GitHub Desktop.
// build: c++ -std=c++14 fizzbuzz.js.cpp
#include <iostream>
#define function auto
#define var auto
class Console {
public:
void log(std::string msg) {
std::cout << msg << std::endl;
}
void log(int msg) {
std::cout << msg << std::endl;
}
};
auto console = Console();
function fizzbuzz() {
var i = 1;
while (i <= 100) {
if (i % 15 == 0) {
console.log("FizzBuzz");
} else if (i % 3 == 0) {
console.log("Fizz");
} else if (i % 5 == 0) {
console.log("Buzz");
} else {
console.log(i);
}
i++;
}
}
int main()
{
fizzbuzz();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment