#include <stdio.h>
int n=10;
int sumScore(int score[]){
int i=0;
int sum=0;
for(i;i<n;i++)
{
sum+=score[i];
}
//printf("成绩之和为:%d\n",sum);
return sum;
}
double avrScore(int score[]){
double avr=sumScore(score)/n;
//printf("平均成绩为:%1.2f\n",avr);
return avr;
}
int B_S(int score[]){
int i,j;
for(j=8;j>=0;j--){
for(i=0;i<=j;i++){
if(score[i]<score[i+1]){
int temp;
temp=score[i];
score[i]=score[i+1];
score[i+1]=temp;
}
}
}
for(i=0;i<n;i++)
{
printf("第%d名:%d\n",(i+1),score[i]);
}
return 0;
}
int bigScore(int score[]){
int i,j;
for(j=8;j>=0;j--){
for(i=0;i<=j;i++){
if(score[i]<score[i+1]){
int temp;
temp=score[i];
score[i]=score[i+1];
score[i+1]=temp;
}
}
}
return score[0];
}
int smallScore(int score[]){
int i,j;
for(i=0;i<=j;i++){
if(score[i]<score[i+1]){
int temp;
temp=score[i];
score[i]=score[i+1];
score[i+1]=temp;
}
}
return score[n-1];
}
int main()
{
int score[10]={67,98,75,63,82,79,81,91,66,84};
printf("总成绩为:%d\n",sumScore(score));
printf("平均成绩为:%1.2f\n",avrScore(score));
printf("最高成绩:%d\n",bigScore(score));
printf("最低成绩:%d\n",smallScore(score));
printf("成绩排名情况:\n");
B_S(score);
return 0;
}
= =..确实有点。。。