#include<stdio.h>
float average(float ar[ ],int n)
{
int i;
float sum = 0;
for ( i = 0; i < n; i++)
{sum = sum + ar[i];
printf("%f\n",ar[i]);
}
return sum / n;
}
int main()
{
float score1[5] = {84,72,90,87,65};
float score2[10] = {72,68,93,55,89,75,62,88,95,70 };
printf("average score1 is: %f\n",average(score1, 5));
printf("average score2 is: %f\n",average(score2, 10));
}
2020-12-11
最新推荐文章于 2025-01-01 12:40:30 发布