首页 > 其他 > 详细

026.程序流程结构-选择结构-嵌套if语句

时间:2021-09-05 23:25:28      阅读:26      评论:0      收藏:0      [点我收藏+]
#include <iostream>
using namespace std;
int main()
{
    //选择结构 单行if语句
    //用户输入分数,如果分数大于600,视为考上一本大学,在屏幕上输出

    //1.用户输入分数
    int scroe = 0;
    cout << "请输入一个分数:" << endl;
    cin >> scroe;

    //2.打印用户输入的分数;
    cout << "你输入的分数是:" << scroe << endl;

    //3.判断分数是否大于600,如果大于600,输出
    //注意事项,if条件后面不要加分号;

    if (scroe > 600)
    {
        if (scroe > 700)
        {
            cout << "你考上北大" << endl;
        }
        else if (scroe > 650)
        {
            cout << "你考上清华" << endl;
        }

        else
        {
            cout << "你考上人大" << endl;
        }


    }


    else if (scroe > 500)
    {
        cout << "你考上的是二本大学" << endl;
    }
    else if (scroe > 400)
    {
        cout << "你考上的是三本大学" << endl;
    }
    else
    {
        cout << "你未考上的大学" << endl;
    }
    system("pause");
    return 0;
}

 

026.程序流程结构-选择结构-嵌套if语句

原文:https://www.cnblogs.com/ceovs/p/15225719.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!