取三数平均值显示等级

输入三门功课成绩,取三门成绩平均值显示等级。(100-90为优秀,90-80为良,80-70为中,70-60为及格,<60为不及格)

#include <iostream>
using namespace std;

int main() {
    double score1, score2, score3, avg;
    cout << "请输入三门功课成绩:";
    cin >> score1 >> score2 >> score3;
    avg = (score1 + score2 + score3) / 3.0;
    if (avg >= 90) {
        cout << "等级:优秀" << endl;
    } else if (avg >= 80) {
        cout << "等级:良" << endl;
    } else if (avg >= 70) {
        cout << "等级:中" << endl;
    } else if (avg >= 60) {
        cout << "等级:及格" << endl;
    } else {
        cout << "等级:不及格" << endl;
    }
    return 0;
}

如果以上回答对您有所帮助,点击一下采纳该答案~谢谢

#include <iostream>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    double avg = (a+b+c)/3.0;
    if(avg >= 90)
        cout<<"优秀";
    else if(avg >= 80)
        cout<<"良";
    else if(avg >= 70)
        cout<<"中";
    else if(avg >= 60)
        cout<<"及格";
    else
        cout<<"不及格";
}