Skip to content

Instantly share code, notes, and snippets.

@fa7ad
Last active March 10, 2016 12:23
Show Gist options
  • Save fa7ad/2d1682a59aaa613d6854 to your computer and use it in GitHub Desktop.
Save fa7ad/2d1682a59aaa613d6854 to your computer and use it in GitHub Desktop.
Original code by fb/fariha.tasnim.9469 | Problem: https://algo.codemarshal.org/problems/556c9f097b4cec0300d4ab93
#include <iostream>
#include <string>
#include <sstream>
// Prototype
void clearBuf();
int main(){
int lines;
std::cin >> lines;
clearBuf();
std::ostringstream output;
for(int x = 0; x < lines; x++){
std::string line;
std::cin >> line;
int length = line.length();
int sum = 0;
int lastchar = (line[length-1] - '0');
for(int c = 0; c < length; c++){
sum += (line[c] - '0');
}
if( lastchar == 0 || lastchar == 5 ){
if(sum % 3 == 0){
output << "Case " << x+1 << ": FizzBuzz\n";
}else{
output << "Case " << x+1 << ": Buzz\n";
}
}else if(sum % 3 == 0){
output << "Case " << x+1 << ": Fizz\n";
}else if(sum % 3 != 0 && lastchar != 0 && lastchar != 5){
output << "Case " << x+1 << ": Null\n";
}
}
std::cout << output.str();
return 0;
}
void clearBuf(){
int ch;
while((ch = std::cin.get()) != std::cin.eof() && ch != '\n');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment