文章目录
- AcWing 661. 平均数3
- AC代码
AcWing 661. 平均数3
本题链接:AcWing 661. 平均数3
本博客给出本题截图:
AC代码
代码:
#include <iostream> #include <cstdio> using namespace std; int main() { double a, b, c, d, ave; cin >> a >> b >> c >>d; ave = a * 0.2 + b * 0.3 + c * 0.4 + d * 0.1; printf("Media: %.1lf\n", ave); if (ave >= 7.0) cout << "Aluno aprovado."; else if (ave < 5.0) cout << "Aluno reprovado."; else { cout << "Aluno em exame." << endl; double y; cin >> y; printf("Nota do exame: %.1lf\n", y); ave = (ave + y) / 2.0; if (ave >= 5.0) cout << "Aluno aprovado.\n"; else cout << "Aluno reprovado.\n"; printf("Media final: %.1lf", ave); } return 0; }