C++入门经典-例3.4-根据成绩划分等级

1:代码如下:

// 3.4.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include <iostream>
using namespace std;
void main()
{
    cout<<"输入成绩"<<endl;
    int iInput;
    cin >> iInput;
    if(iInput>=90)
    {
        cout << "优秀" <<endl;
    }
    else if(iInput>=80&& iInput<90)
    {
        cout << "良好" <<endl;
    }
    else if(iInput>=70 && iInput <80)
    {
        cout << "一般" <<endl;
    }
    else if(iInput>=60 && iInput <70)
    {
        cout << "及格" <<endl;
    }
    else if(iInput<60&&iInput>=0)
    {
        cout << "考试不及格,请再加把劲" <<endl;
    }
    else
    {
        cout<<"输入有误"<<endl;
    }
}
View Code

运行结果:

原文地址:https://www.cnblogs.com/lovemi93/p/7506596.html