#include<iostream>
#include<cstring>
#include <sstream>
int main()
{
constchar comma = ',';
std::cout << "Please enter a sequence of numbers separated by commas on a single line\n";
std::string line;
std::getline(std::cin, line); // read the complete line as a string
std::cout << "you entered: " << line << '\n';
line += comma; // append a comma at the end; this will make our processing simpler
std::istringstream strstm(line); // construct a string stream which can read integers from the line
int number;
char separator;
while (strstm >> number >> separator && separator == comma) // for each number read from the line
{
constbool divisible_by_3 = number % 3 == 0;
constbool divisible_by_5 = number % 5 == 0;
std::cout << number << " - ";
if (divisible_by_3 && divisible_by_5) std::cout << "FizzBuzz\n";
elseif (divisible_by_3) std::cout << "Fizz\n";
elseif (divisible_by_5) std::cout << "Buzz\n";
else std::cout << "Please select a different number.\n";
}
}