fork download
  1. #include <iostream>
  2.  
  3. typedef std::pair<int, bool> DType;
  4.  
  5. DType Fizz(int N){
  6.  
  7. bool F = false;
  8.  
  9. if (N == 0) return std::make_pair(N, false);
  10. if (N % 3==0){
  11. std::cout << "Fizz" << ',';
  12. F = true;
  13. }
  14.  
  15. return std::make_pair(N, F);
  16. }
  17.  
  18. DType Fizz(DType P){
  19. DType T = Fizz(P.first);
  20. bool F = (P.second | T.second);
  21. return std::make_pair(T.first,F);
  22. }
  23.  
  24. DType Buzz(int N){
  25.  
  26. bool F = false;
  27.  
  28. if (N == 0) return std::make_pair(N, false);
  29. if (N % 5==0){
  30. std::cout << "Buzz" << ',';
  31. F = true;
  32. }
  33.  
  34. return std::make_pair(N, F);
  35. }
  36.  
  37. DType Buzz(DType P){
  38. DType T = Buzz(P.first);
  39. bool F = (P.second | T.second);
  40. return std::make_pair(T.first,F);
  41. }
  42.  
  43. DType Gizz(int N){
  44.  
  45. bool F = false;
  46.  
  47. if (N == 0) return std::make_pair(N, false);
  48. if (N % 7==0){
  49. std::cout << "Gizz" << ',';
  50. F = true;
  51. }
  52.  
  53. return std::make_pair(N, F);
  54. }
  55.  
  56. DType Gizz(DType P){
  57. DType T = Gizz(P.first);
  58. bool F = (P.second | T.second);
  59. return std::make_pair(T.first,F);
  60. }
  61. int main(){
  62.  
  63. std::cout << 1 << ':'; if (Gizz(Buzz(Fizz(1))).second == false) std::cout << 1;std::cout << std::endl;
  64. std::cout << 3 << ':'; if (Gizz(Buzz(Fizz(3))).second == false) std::cout << 3;std::cout << std::endl;
  65. std::cout << 5 << ':'; if (Gizz(Buzz(Fizz(5))).second == false) std::cout << 5;std::cout << std::endl;
  66. std::cout << 7 << ':'; if (Gizz(Buzz(Fizz(7))).second == false) std::cout << 7;std::cout << std::endl;
  67. std::cout << 21 << ':';if (Gizz(Buzz(Fizz(21))).second == false) std::cout << 21;std::cout << std::endl;
  68. std::cout << 35 << ':';if (Gizz(Buzz(Fizz(35))).second == false) std::cout << 35;std::cout << std::endl;
  69. std::cout << 105 << ':'; if (Gizz(Buzz(Fizz(105))).second == false) std::cout <<105 ;std::cout << std::endl;
  70. std::cout << 105 << ':'; if (Buzz(Gizz(Fizz(105))).second == false) std::cout <<105 ;std::cout << std::endl;
  71. std::cout << 997 << ':'; if (Gizz(Buzz(Fizz(997))).second == false) std::cout <<997 ;std::cout << std::endl;
  72. std::cout << 999 << ':'; if (Gizz(Buzz(Fizz(999))).second == false) std::cout <<999 ;std::cout << std::endl;
  73.  
  74. std::cout << "------List Of 50------" << std::endl;
  75. /**/
  76. for (int i = 0; i < 50; i++){
  77. if (Gizz(Buzz(Fizz(i))).second == false) std::cout << i;
  78. std::cout << std::endl;
  79. }
  80. /**/
  81. return 0;
  82. }
Success #stdin #stdout 0s 3344KB
stdin
Standard input is empty
stdout
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,