Skip to content

Instantly share code, notes, and snippets.

@mobeigi
Created April 11, 2015 05:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mobeigi/a467ab5091319b738438 to your computer and use it in GitHub Desktop.
Save mobeigi/a467ab5091319b738438 to your computer and use it in GitHub Desktop.
C++ Fizzbuzz solution
#include <iostream>
#include <string>
int main()
{
for (int i = 1; i <= 100; ++i) {
std::string ans;
ans += (i % 3 == 0) ? "Fizz" : "";
ans += (i % 5 == 0) ? "Buzz" : "";
ans += (ans.empty()) ? std::to_string(i) : "";
std::cout << ans << std::endl;
}
return 0;
}
@audunolsen
Copy link

Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment