• Source
    1. #include <iostream>
    2. using namespace std;
    3. void decideBuyIphoneVer1(bool cond1, bool cond2, bool cond3) {
    4. if (cond1)
    5. if (cond2)
    6. if (cond3)
    7. printf("You will buy IPHONE X\n");
    8. else
    9. printf("You will not buy IPHONE X\n");
    10. else
    11. printf("You will not buy IPHONE X\n");
    12. else
    13. printf("You will not buy IPHONE X\n");
    14. }
    15. void decideBuyIphoneVer2(bool cond1, bool cond2, bool cond3) {
    16. if (cond1 && cond2 && cond3)
    17. printf("You will buy IPHONE X\n");
    18. else
    19. printf("You will not buy IPHONE X\n");
    20. }
    21. int main() {
    22. bool haveMoney = false;
    23. bool wantToBuy = false;
    24. bool needToBuy = false;
    25.  
    26. //Use version1 or version2 for decision?
    27. decideBuyIphoneVer1(haveMoney, wantToBuy, needToBuy);
    28. decideBuyIphoneVer2(haveMoney, wantToBuy, needToBuy);
    29.  
    30. return 0;
    31. }