求教,哪里错了
#include<stdio.h>
void rank1(int arr[])
{
for (int i = 0; i < 9; i++)
{
for (int j = 0; j < 10; j++)
{
int max;
if (arr[j + 1] > arr[j])
{
max = arr[j + 1];
arr[j + 1] = arr[j];
arr[j] = max;
}
}
}
for (int m = 0; m < 10; m++)
{
printf("%d,", arr[m]);
}
printf("\n");
}
void rank2(int arr[])
{
for (int i = 0; i < 9; i++)
{
for (int j = 0; j < 10; j++)
{
int min;
if (arr[j + 1] < arr[j])
{
min = arr[j + 1];
arr[j + 1] = arr[j];
arr[j] = min;
}
}
}
for (int m = 0; m < 10; m++)
{
printf("%d,", arr[m]);
}
printf("\n");
}
int sumandavr(int arr[])
{
int i = 0;
double a = 0;
for (int j = 0; j < 10; j++)
{
i += arr[j];
}
printf("\n总和为%d", i);
a = i / 10;
printf("\n平均为%lf", a);
return 0;
}
int best(int arr[])
{
int m = arr[0];
for (int i = 0; i < 9; i++)
{
if (arr[i + 1] > m)
{
m = arr[i + 1];
}
}
printf("\n最好的成绩为%d", m);
return 0;
}
int worst(int arr[])
{
int m = arr[0];
for (int i = 0; i < 9; i++)
{
if (arr[i + 1] < m)
{
m = arr[i + 1];
}
}
printf("\n最差的成绩为%d", m);
return 0;
}
int main()
{
int score[10] = { 67,98,75,63,82,79,81,91,66,84 };
rank1(score);
rank2(score);
sumandavr(score);
best(score);
worst(score);
return 0;
}
我这样报错了,求教