#include<stdio.h>
#include<string.h>
#define N 3
struct staff{
char name[20];
long int num;
short age;
int year;
float salary;
};
void average(struct staff men[],int i);
main()
{
int i;
static struct staff men[N];
struct staff *p;
p=men;
printf("Input data:name,number,age,begin year, salary\n");
for(i=0;i<N;i++)
{scanf("%s",p->name);
if(strcmp(p->name,"ok")==0)
{printf ("data end!\n");
break;}
scanf("d%d%d%",&p->num,&p->age,&p->year);
scanf("%f",&p->salary);
p++;
}
average(men,i);
return 0;
}
void average(struct staff men[],int i)
{
int j,sum_a=0,sum_w=0;
int y,ave_age,ave_w;
float ave_slr,sum_s=0;
printf("Input the number of this year.\n");
scanf("%d",&y);
for(j=0;j<=i;j++)
{
sum_a+=men[j].age;
sum_w+=y-men[j].year;
sum_s+=men[j].salary;
}
ave_age=sum_a/i;
ave_w=sum_w/i;
ave_slr=sum_s/i;
printf("The average of age=%d\n",ave_age);
printf("The average of employed time=%d\n",ave_w);
printf("The average of salary=%f\n",ave_slr);
}
怎么运行啊?我怎么运行不出结果呢????