填空题

给定程序BLANK1.C中,函数fun的功能是在数组中找出两科成绩之和最高的学生并返回其在数组中的下标。对所给函数int fun(STU*d,int n),主函数传给形参d的是学生数组名,而传给形参n的是该数组中学生的个数。


例如,若学生数组数据为:

2016500301李清水83 92

2016500336 刘世才85 94

2016500371王子晨88 88

则调用该函数后,程序输出为:2016500336刘世才85 94

请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。

注意:不得增行或删行,也不得更改程序的结构!

#include<stdio.h>

typedef struct stu

{

    char ID[30];

    char name[20];

    int score[2];

} STU;

int fun(STU *d,int n)

{

    int i,m;

    /******found******/

    ______(1)______;

    for(i=1;i<n;i++)

    /******found******/

        if(d[i].score[0]+d[i].score[1]>________(2)________)

            m=i;

    /******found******/

    ______(3)______;

}

 

void main()

{

    STU a[10]={ "2016500301","李清水",83,92,"2016500336","刘世才",85,94,"2016500371","王子晨",88,88};

    int i,n=3;

    i=fun(a,n);

    printf("%30s%20s%4d%4d",a[i].ID,a[i].name,a[i].score[0],a[i].score[1]);

    printf("\n");

}

赣ICP备20007335号-2