#include <iostream> typedef std::pair<int, bool> DType; DType Fizz(int N){ bool F = false; if (N == 0) return std::make_pair(N, false); if (N % 3==0){ std::cout << "Fizz" << ','; F = true; } return std::make_pair(N, F); } DType Fizz(DType P){ DType T = Fizz(P.first); bool F = (P.second | T.second); return std::make_pair(T.first,F); } DType Buzz(int N){ bool F = false; if (N == 0) return std::make_pair(N, false); if (N % 5==0){ std::cout << "Buzz" << ','; F = true; } return std::make_pair(N, F); } DType Buzz(DType P){ DType T = Buzz(P.first); bool F = (P.second | T.second); return std::make_pair(T.first,F); } DType Gizz(int N){ bool F = false; if (N == 0) return std::make_pair(N, false); if (N % 7==0){ std::cout << "Gizz" << ','; F = true; } return std::make_pair(N, F); } DType Gizz(DType P){ DType T = Gizz(P.first); bool F = (P.second | T.second); return std::make_pair(T.first,F); } int main(){ std::cout << 1 << ':'; if (Gizz(Buzz(Fizz(1))).second == false) std::cout << 1;std::cout << std::endl; std::cout << 3 << ':'; if (Gizz(Buzz(Fizz(3))).second == false) std::cout << 3;std::cout << std::endl; std::cout << 5 << ':'; if (Gizz(Buzz(Fizz(5))).second == false) std::cout << 5;std::cout << std::endl; std::cout << 7 << ':'; if (Gizz(Buzz(Fizz(7))).second == false) std::cout << 7;std::cout << std::endl; std::cout << 21 << ':';if (Gizz(Buzz(Fizz(21))).second == false) std::cout << 21;std::cout << std::endl; std::cout << 35 << ':';if (Gizz(Buzz(Fizz(35))).second == false) std::cout << 35;std::cout << std::endl; std::cout << 105 << ':'; if (Gizz(Buzz(Fizz(105))).second == false) std::cout <<105 ;std::cout << std::endl; std::cout << 105 << ':'; if (Buzz(Gizz(Fizz(105))).second == false) std::cout <<105 ;std::cout << std::endl; std::cout << 997 << ':'; if (Gizz(Buzz(Fizz(997))).second == false) std::cout <<997 ;std::cout << std::endl; std::cout << 999 << ':'; if (Gizz(Buzz(Fizz(999))).second == false) std::cout <<999 ;std::cout << std::endl; std::cout << "------List Of 50------" << std::endl; /**/ for (int i = 0; i < 50; i++){ if (Gizz(Buzz(Fizz(i))).second == false) std::cout << i; std::cout << std::endl; } /**/ return 0; }
Standard input is empty
1:1 3:Fizz, 5:Buzz, 7:Gizz, 21:Fizz,Gizz, 35:Buzz,Gizz, 105:Fizz,Buzz,Gizz, 105:Fizz,Gizz,Buzz, 997:997 999:Fizz, ------List Of 50------ 0 1 2 Fizz, 4 Buzz, Fizz, Gizz, 8 Fizz, Buzz, 11 Fizz, 13 Gizz, Fizz,Buzz, 16 17 Fizz, 19 Buzz, Fizz,Gizz, 22 23 Fizz, Buzz, 26 Fizz, Gizz, 29 Fizz,Buzz, 31 32 Fizz, 34 Buzz,Gizz, Fizz, 37 38 Fizz, Buzz, 41 Fizz,Gizz, 43 44 Fizz,Buzz, 46 47 Fizz, Gizz,