一个C语言的问题,求解答

下列程序的功能是统计班级35名学生成绩的最高分,在函数fun()的{}中填入代码。

#include<stdio.h> void main(){
float score[35],max; int i;
float fun(float[],int); for(i=0;i<35;i++)
scanf("%f",&score[i]); max=fun(score,35); printf("%f\n",max);

float fun(float s[,intn)/n为需要处理的数组元素的个数/

函数为这样,有用望采纳

float fun(float s[],int n)
{
    int max=s[0];
    for(int i=0;i<n;++i)
    {
        if(s[i]>max)
        {
            max=s[i];
        }
    }
    return max;
}

解答如下

img

#include<stdio.h>
float fun(float s[],int n)//n为需要处理的数组元素的个数/
{
    float max=s[n-1];
    for(int i=0; i<n-1; i++)
    {
        if(s[i]>max)
        {
            max=s[i];
        }
    }
    return max;
}
int main()
{
    float score[35],max;
    int i;
    float fun(float[],int);
    for(i=0; i<35; i++)
        scanf("%f",&score[i]);
    max=fun(score,35);
    printf("%f\n",max);
}