填空题
给定程序中,函数fun的功能是将形参std所指结构体数组中年龄最大者的数据作为函数值返回,并在main函数中输出。
#include<stdio.h>
typedef struct
{char name[10];
int age;
}STD;
STD fun(STD std[],int n)
{STD max;int i;
max=______; /*第一空*/
for(i=1;i<n;i++)
if(max.age<______)max=std[i];/*第二空*/
return max;
}
main()
{STD std[5]={"aaa",17,"bbb",16,"ccc",18,"ddd",17,"eee",15};
STD max;
max=fun(std,5);
printf("\n the result:\n");
printf("\nName:%s,Age:%d\n",______,max.age); /*第三空*/
}
【参考答案】
std[0]
std[i].age
max.name