题目描述
把权数总数当10必爆 为了四舍五入就把它当作1吧~
这样可以ac 而不是像乘以权重再除以10一样无法四舍五入
C++ 代码
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
double a1,a2,a3,a4;
cin>>a1>>a2>>a3>>a4;
double x,y,z;
x=(a1*0.2+a2*0.3+a3*0.4+a4*0.1);
printf("Media: %.1lf\n",x);
if(x>=7)
cout<<"Aluno aprovado."<<endl;
if(x<5)
cout<<"Aluno reprovado."<<endl;
if(x>=5&&x<7)
{
cout<<"Aluno em exame."<<endl;
cin>>y;
printf("Nota do exame: %.1lf\n",y);
z=(x+y)/2;
if(z>=5)
cout<<"Aluno aprovado."<<endl;
else
cout<<"Aluno reprovado."<<endl;
printf("Media final: %.1lf",z);
}
return 0;
}
妙啊
这个题方法比较巧,哈哈