平均分大了一倍那样,希望大佬解答
#include <stdio.h>
int sum = 0.00;
int max;
int min;
double maen;
int i;
int j;
int summation(int score[])
{
for(i = 0; i < 10; i++)
{
sum += score[i];
}
return sum;
}
int maximal(int score[])
{
max = score[0];
for(i = 0; i < 10; i++)
{
if(score[i] > max)
{
max = score[i];
}
}
return max;
}
int minimum(int score[])
{
min = score[0];
for(i = 0; i<10; i++)
{
if(score[i] < min)
{
min = score[i];
}
}
return min;
}
double average(int score[])
{
double a = summation(score);
maen = a / 10;
return maen;
}
void descending_order(int score[])
{
for(i = 0; i < 9; i++)
{
for(j = 0; j <= i; j++)
{
int n = 0;
if(score[j] > score[j + 1])
{
n = score[j];
score[j] = score[j + 1];
score[j + 1] = n;
}
}
}
for(i = 0; i < 10; i++)
{
if(i < 9)
{
printf("%d, ", score[i]);
}else{
printf("%d", score[i]);
}
}
}
int main()
{
int score[10]={67,98,75,63,82,79,81,91,66,84};
printf("班级总分为:%d\n", summation(score));
printf("班级的最高分为:%d\n", maximal(score));
printf("班级的最低分为:%d\n", minimum(score));
printf("班级的平均分为:%.2f\n", average(score));
descending_order(score);
}