黒馬プログラマーC++学習ノート

2791 ワード

1.if文で使用される論理問題【未解決】について
/*          
   :copyright*/
#include
using namespace std;

int main()
{
    //       if  
    float score = 0;
    cout << "       " << endl;
    cin >> score;
    cout << "       " << score << endl;
    if (score >= 600)
    {
        cout << "          " << endl;
    }
    else if(500 <= score < 600)
    {
        cout << "  " << endl;
    }
    else if(score > 400)
    {
        cout << "  " << endl;
    }
    else
    {
        cout << "nothing" << endl;
    }
    
    
}

66を入力すると、プログラムは2冊出力され、debug時にプログラムが直接実行されていることがわかります.
else if(500 <= score < 600)
    {
        cout << "  " << endl;
    }