1 回答
TA贡献18条经验 获得超9个赞
#include<iostream>
using namespace std;
int main(){
int a[20]={60,30,30,100,10,90,80,30,0,32,60,100,99,100,100,12,34,56,100,99};
int max=0,min=0,sum=0,outstanding=0,good=0,fail=0;
double average=0.0;
for(int i=0;i<20;i++){
//cin>>a[i];
if(a[i]<0){
cout<<"wrong data,input again"<<endl;
i--;
}
else{
sum+=a[i];
if(max<a[i])
max=a[i];
if(min>a[i])
min=a[i];
if(a[i]>80)
outstanding++;
else if(a[i]<60)
fail++;
else{
good++;
}
}
}
average=sum/20.0;
cout<<"最高分为:"<<max<<endl;
cout<<"最低分为:"<<min<<endl;
cout<<"平均分为:"<<average<<endl;
cout<<"优秀人数为:"<<outstanding<<endl;
cout<<"合格人数为:"<<good<<endl;
cout<<"不合格人数为:"<<fail<<endl;
return 0;
}
- 1 回答
- 0 关注
- 1106 浏览
添加回答
举报