有点长
程序如下:
#include<stdio.h>
main()
{
int score[20],i=0,j=0,sum=0,average,max,min,t,A=0,B=0,C=0,D=0,E=0;
printf("please input scores of 20 students:\n");
for(i=0;i!=20;++i)
{
scanf("%d",&score[i]);
sum=sum+score[i];
switch(score[i]/10)
{
case 9:
++A;
break;
case 8:
++B;
break;
case 7:
++C;
break;
case 6:
++D;
break;
default:
++E;
break;
}
}
average=sum/20;
while(j!=20)
{
for(i=j;i!=20;++i)
{
if(score[j]<score[i])
{
t=score[j];
score[j]=score[i];
score[i]=t;
}
}
++j;
}
max=score[0];
min=score[19];
printf("The average score of students is %d\n",average);
printf("The highest score is %d\nThe lowest score is%d\n",max,min);
printf("The number of more than 90: %d\n",A);
printf("The number of 80-89: %d\n",B);
printf("The number of 70-79: %d\n",C);
printf("The number of 60-69: %d\n",D);
printf("The number of less than 60: %d\n",E);
printf("All scores are:\n");
for(i=0;i!=20;++i)
printf("%d ",score[i]);
}
温馨提示:答案为网友推荐,仅供参考