fork download
  1. #include <iostream>
  2. #include <stdio.h>
  3. using namespace std;
  4.  
  5. struct Tracker
  6. {
  7. Tracker() : any(false) { }
  8. bool operator()() { any = true; return true; }
  9. bool any;
  10. };
  11.  
  12. void Properties(int thing) {
  13. Tracker tracker;
  14. if (thing % 3 == 0 && tracker()) {
  15. printf("\"%d\" is a multiple of three.\n", thing);
  16. }
  17. if (thing > 100 && tracker()) {
  18. printf("\"%d\" is greater than one hundred.\n", thing);
  19. }
  20. if (thing > 1000 && tracker()) {
  21. printf("\"%d\" is greater than one thousand.\n", thing);
  22. }
  23. if (!tracker.any) {
  24. printf("\"%d\" is boring.\n", thing);
  25. }
  26. }
  27.  
  28. int main() {
  29. Properties(101);
  30. Properties(100);
  31. Properties(1002);
  32. return 0;
  33. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
"101" is greater than one hundred.
"100" is boring.
"1002" is a multiple of three.
"1002" is greater than one hundred.
"1002" is greater than one thousand.