给定程序中,函数fun的功能是:将形参std所指结构体数组中年龄最大者的...

给定程序中,函数fun的功能是:将形参std所指结构体数组中年龄最大者的...,第1张

#include <stdio.h>

typedef struct

{ char name[10];

int age;

}STD;

STD fun(STD std[],int n)

{ STD max; int i;

max=std[0];

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

if(max.age<std[i].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("\nThe result:\n");

printf("\nName:%s,Age:%d\n",std[max].name,max.age);

第一空,PERSON std[] 或者 PERSON *std,将学生数组作为参数,从后面的“std[0]”下标能够推断出参数是数组类型(指针类型);

第二空,PERSON temp,这一点从“temp=std[0]”可以推断出temp的类型;

第三空,fun(std),将std数组作为形参传入到函数。


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/11141591.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-13
下一篇 2023-05-13

发表评论

登录后才能评论

评论列表(0条)

保存