麻烦帮忙调试一下代码
找找错误在哪?#include<stdio.h>
#include<stdlib.h>
#define num 1
#define res 30
typedef struct employee
{
int age;
char name[10];
double salary;
}PEMP;
//输入函数
void update(PEMP company[])
{
int i;
PEMP emp;
if((PEMP *)malloc(num*sizeof(PEMP))==NULL)
exit(0);
printf("共有%d位员工请输入信息:\n",num);
for(i=0;i<num;i++)
{
scanf("%d,%s,%lf",&emp.age,emp.name,&emp.salary);
company[i]=emp;
}
printf("%d位员工信息为:\n",num);
for(i=0;i<num;i++)
{
printf("%d,%s,%f\n",company[i].age,company[i].name,company[i].salary);
}
}
//对年龄大于age的工资求和
double total(PEMP company[],int age)
{
double sum=0.0;
int i;
for(i=0;i<num;i++)
if(company[i].age>=age)
sum+=(company[i].salary);
return(sum);
}
//对年龄大于age的工资求平均值
double mean(PEMP company[],int age)
{
int i;
double average=0.0;
for(i=0;i<num;i++)
if(company[i].age>=age)
{
average+=(company[i].salary);
}
return(average/(++i));
}
void main()
{
PEMP company[num]={0};
update(company);
printf("total=%g\n",total(company,res));
printf("mean=%g\n",mean(company,res));
}