2013年计算机二级C语言上机试题七十四及答案

2014-11-23 19:23:31 · 作者: · 浏览: 24

  一、填空题
  给定程序中,函数fun的功能是:将形参std所指结构体数组中年龄最大者的数据作为函数值返回,并在main函数中输出。
  请勿改动主函数main和其它函数中的任何内容,仅在fun函数的横线上填入所编写的若干表达式或语句。
  #include
  typedef struct
  {
  char name[10];
  int age;
  } STD;
  STD fun(STD std[], int n)
  {
  STD max;
  int i;
  max = ___1___;

  for (i=1; i   if (max.age < ___2___)
  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", ___3___, max.age);
  }