#include
#include
#define num 10
typedef struct employee{
int age;
char *name;
double salary;
}*PEMP;
void update(PEMP*,int,int,char*,double);
double total(PEMP*);
double mean(PEMP*);
void readin(PEMP*);
void main()
{PEMP company[num];
double x;
int i;
readin(company);
for(i=0;i
x=total(company);
printf("total=%8.2f\n",x);
printf("mean=%g\n",mean(company));
}
void update(PEMP company[],int id,int age,char*name,double salary)
{PEMP emp;
if((emp=(PEMP)malloc(sizeof(struct employee)))==NULL)
return;
emp->age=age;
emp->salary=salary;
emp->name=name;
company[id]=emp;
}
}
double total(PEMP company[],int n)
{
int i,age1,age2;
double sum=0;
for(;;)
{
printf("Please input the age range:") ;
scanf("%d%d",&age1,&age2);
if(age1>age2)
{i=age1;age1=age2;age2=i;}
if((age1<=0)&&(age1<=70)&&(age2>=0)&&(age2<=70)&&(age2>age1)) break;
}
for(i=0;i
sum+=(company[i]->salary);
return(sum);
} 后面还有一段 太长了加不上来 求大神指点