回复 5楼 fc176154001
#include"stdio.h"
#define N 5
struct date
{
int year;
int month;
int day;
};
struct salary
{
double basepay;//基本工资
double subsidy;//津贴
double titsubsidies;//职称补贴
};
struct teacher
{
int num;
char name[10];
char profession[30];
struct salary
gongzi;
struct date birthday;
double sumgongzi;
};
int main()
{
struct teacher te[N];//结构体变量的定义
int i,sum;
printf("按顺序输入职工编号、姓名、职称、工资、出生日期:\n");
for(i=0;i<N;i++)
{
printf("输入教师职工 %d 的信息:",i+1);
scanf("%d",&te[i].num);
scanf("%s",te[i].name);
scanf("%s",te[i].profession);
scanf("%f%f%f",&te[i].gongzi.basepay,&te[i].gongzi.subsidy,
&te[i].gongzi.titsubsidies);
scanf("%d.%d.%d",&te[i].birthday.year,&te[i].birthday.month,
&te[i].birthday.day);
te[i].sumgongzi=te[i].gongzi.basepay+te[i].gongzi.subsidy
+te[i].gongzi.titsubsidies;
}
printf("\n工资大于5000的教师信息:");
for(i=0;i<N;i++)
{
if(te[i].sumgongzi>5000)
{
printf("%d",te[i].num);
printf("%s",te[i].name);
printf("%s",te[i].profession);
printf("%f%f%f",te[i].gongzi.basepay,te[i].gongzi.subsidy,
te[i].gongzi.titsubsidies);
printf("%d.%d.%d",te[i].birthday.year,te[i].birthday.month,
te[i].birthday.day);
printf("\n");
}
}
}