首页 > 解决方案 > 如何解决:else 语句未被调用 c++

问题描述

所以我有这个项目,我正在使用嵌套的 if 语句,但我的 else 语句没有被调用,我尝试在括号周围移动,但没有运气......

cout << "WELCOME TO OLIVER'S CHOOSE YOUR OWN ADEVTURE\n\n";
cout << "Would you like to go down the hard path or the easypath? \n\n>";
cin >> R1;
if (R1 == "hard" || "Hard") {
    cout << "you chose the hard path... ";
    cout << "\nYou stumbled upona pool and a cow where do you want to go? (pool / cow) d\n\n>";
    cin >> R2;
    if (R2 == "pool" || "Pool") {
        cout << "\n\ncongrats ur swimming do you want to fight the water snake or swim away (fight / swim)";
        cout << "\n\n>";
        cin >> R4;
        if (R4 == "fight" || "Fight") {
            cout << "\n\nNice you won... ";
        }

        else {
            cout << "you swam away but you sadly drowned and i'm now upset i wanted you to win... ;(";
        }
    }
    else {
        cout << "\n\nYou fought the cow... YOU WON do you want to eat it's meat? (yes or no) \n\n>";
        cin >> R5;
        if (R5 == "Yes" || "yes") {
            cout << "\n\nyou didn't cook it you die now ggs";
        }
        else {
            cout << "\n\nyou starved you die.I had my money on u y u di ?";
        }
    }
}
else {
    cout << "you chose the easy path"; 

输入 Easy / Easy 输出“你选择了硬路……”

标签: c++

解决方案


推荐阅读