zoukankan      html  css  js  c++  java
  • if语句的选择结构

    #include<iostream>
    using namespace std;
    int main()
    {
        int grad;
        cout<<"请输入你要查询的成绩:"<<endl;
        cin>>grad;
        if(grad>100)
            cout<<"您输入的数据错误";
        else if(grad>=90&&grad<=100)
            cout<<"A";
        else if(grad>=80&&grad<90)
            cout<<"B";
        else if(grad>=70&&grad<80)
            cout<<"C";
        else if(grad>=60&&grad<70)
            cout<<"D";
        else
            cout<<"E";
    }

    ————————————————————————————————————

    嵌套的语句——查询成绩

    #include<iostream>
    using namespace std;
    int main()
    {
        int grad;
        cout<<"请输入你要查询的成绩:"<<endl;
        cin>>grad;
        if(grad>100||grad<0)
            cout<<"您输入的数据错误";

        else if(grad<60)
            cout<<"E";
        else
        {
            if(grad<70)
                cout<<"D";
            else
            {
                if(grad<80)
                    cout<<"C";
                else
                {
                    if(grad<90)
                        cout<<"B";
                    else
                        cout<<"A";
                }
            }
        }

    }

  • 相关阅读:
    N皇后
    水域大小
    1221 分割平衡字符串
    1391 检查是否存在有效路径 DFS
    盛最多水的容器11 双指针
    烧饼排序
    每日日报8——软件设计④|抽象工厂模式(人与肤色)
    每日日报5——登录功能的实现(JAVA)
    每日日报4——软件设计②|简单工厂模式(女娲造人)
    vue利用transition过渡动画实现轮播图
  • 原文地址:https://www.cnblogs.com/ywj2013/p/3137305.html
Copyright © 2011-2022 走看看