#include<iostream>
#include<iomanip>
using namespace std;
int average(int *a,int b);
int max1(int *a,int b);
int min1(int *a,int b);
int tongji(int *a,int b);
main()
{
int
i,c[100],n;
cout<<"请输入学生的总人数:";
cin>>n;
cout<<"请输入学生的成绩:"<<endl;
for(i = 0; i < n; i ++)
{
cin>>c[i];
}
average(c,n);
max1(c,n);
min1(c,n);
tongji(c, n);
}
int average(int *a,int b)
{
cout<<'\n';
float i,sum=0,aver=0;
for(i = 0; i < b; i ++)
{
sum+=*a;
a++;
}
aver=sum/b;
cout<<"平均数"<<setw(10)<<aver;
cout<<'\n';
}
int max1(int *a,int b)
{
int i,j,max;
int *e=a;
max=*e;
for(i = 1; i < b; i ++)
{
if(max < e[i])
{
max = e[i];
}
}
cout<<"最高成绩"<<setw(8)<<max;
cout<<'\n';
}
int min1(int *a,int b)
{
int i,j,min;
int *e=a;
min=*e;
for(i = 1; i < b; i ++)
{
if(min > e[i])
{
min = e[i];
}
}
cout<<"最低成绩"<<setw(8)<<min;
cout<<'\n';
cout<<'\n';
}
int tongji(int *a,int b)
{
int i,j;
int countA=0,countB=0,countC=0,countD=0,countE=0;
int *e=a;
for(i = 0; i < b; i ++)
{
if(90 <=e [i]&& e[i] < 100) countA++;
else if(80 <=e [i]&& e[i] < 90) countB++;
else if(70 <= e[i]&& e[i] < 80)
countC++;
else if(60 <= e[i]&& e[i] < 70)
countD++;
else countE++;
}
cout<<"分数段"<<'\t'<<"个数"<<endl;
cout<<"90~100"<<'\t'<<setw(2)<<countA<<endl;
cout<<"80~90"<<'\t'<<setw(2)<<countB<<endl;
cout<<"70~80"<<'\t'<<setw(2)<<countC<<endl;
cout<<"60~70"<<'\t'<<setw(2)<<countD<<endl;
cout<<"0~60"<<'\t'<<setw(2)<<countE<<endl;
}