请教C语言编程高手~~~~~~~~

来源:百度知道 编辑:UC知道 时间:2024/05/21 16:30:00
人员的记录由编号和出生年,月,日组成,N名人员的数据已在主函数中存入结构体数组std中,且编号唯一.函数fun的功能是:找出指定编号人员的数据,作为函数返回,由主函数输出,若指定编号不存在,返回数据中的编号为空串.
在下划线处填入正确内容.
#include <stdio.h>
#include <string.h>
#define N 8
typedef struct
{ char num[10];
int year,month,day ;
}STU;

/**********found**********/
___1___ fun(STU *std, char *num)
{ int i; STU a={"",9999,99,99};
for (i=0; i<N; i++)
/**********found**********/
if( strcmp(___2___,num)==0 )
/**********found**********/
return (___3___);
return a;
}
main()
{ STU std[N]={ {"111111",1984,2,15},{"222222",1983,9,21},{"333333",1984,9,1},
{"444444",1983,7,15},{"555555",1984,9,28},{"666666",1983,11,15},
{"777777",1983,6,22},{"888888",1984,8,19}};
STU p; char n[1

1,STU
2,std->num
3,*std

真不知道这是哪里来找题目...有点汗。

//1处填 STU。 2处填std->num。3处填*std

#include <stdio.h>
#include <string.h>
#define N 8
typedef struct
{ char num[10];
int year,month,day ;
}STU;

/**********found**********/
STU fun(STU *std, char *num)
{ int i; STU a={"",9999,99,99};
for (i=0; i<N; i++)
/**********found**********/
if( strcmp(std->num,num)==0 )
/**********found**********/
return *std;
return a;
}
main()
{ STU std[N]={ {"111111",1984,2,15},{"222222",1983,9,21},{"333333",1984,9,1},
{"444444",1983,7,15},{"555555",1984,9,28},{"666666",1983,11,15},
{"777777",1983,6,22},{"888888",1984,8,19}};
STU p; char n[10]="666666";
p=fun(std,n);
if(p.num[0]==0)
printf("\nNot found