Created
April 11, 2015 05:36
-
-
Save mobeigi/a467ab5091319b738438 to your computer and use it in GitHub Desktop.
C++ Fizzbuzz solution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice!