#include <stdio.h>
int main(){
int score[10]={67,98,75,63,82,79,81,91,66,84};
sortArr(score);
int sum = getSum(score);
printf("总 分:%d\n",sum);
printf("最高分:%d\n",score[9]);
printf("最低分:%d\n",score[0]);
printf("平均分:%f\n",(double)sum/10);
printf("考试成绩降序排序:");
printArr(score);
return 0;
}
//求和
int getSum(int score[10]){
int sum = 0;
for(int i = 0;i<10;i++){
sum += score[i];
}
return sum;
}
//插入排序
void sortArr(int score[10]){
for(int i = 1;i<10;i++){
for(int j = i;j>0;j--){
if(score[j]<score[j-1]){
int temp = score[j];
score[j] =score[j-1];
score[j-1] = temp;
}else{
break;
}
}
}
}
//打印数组
void printArr(int arr[10]){
for(int i = 0;i<10;i++){
if(i==0){
printf("%d",arr[i]);
}else{
printf(",%d",arr[i]);
}
}
printf("\n");
}