当然已有大神反复强调了规范,还是希望题主能遵守。尽管我不排斥void,但我非科班啊,乡下出来的,使的都是野路子,不要学!
主要是两处错误:
1:void level(Employee employee[]);
去掉分号,否则这句就是个函数声明
2:主函数里嵌套其他函数,这是不符合语法的。
代码修改如下编译成功:
程序代码:
#include<stdio.h>
#include<string.h>
#define N 10
typedef struct
{
long num;
char name[10];
char sex;
float score;
}Employee;
Employee employee[N];
void level(Employee employee[])
{
int i,best=0,medium=0,bad=0;
for(i=0;i<N;i++)
if(employee[i].score>=90)
best++;
else if(employee[i].score>=60 && employee[i].score<90)
medium++;
else bad++;
printf("优秀人数:%d\n合格人数:%d\n不合格人数:%d\n",best,medium,bad);
}
void main()
// void print(Employee employee[])
{
int i;
for(i=0;i<N;i++)
{
printf("请输入第%d个职工的信息:\n",i+1);
printf("请输入职工考号:\n");
scanf("%ld",&employee[i].num);
printf("请输入职工姓名:\n");
scanf("%s",&employee[i].name);
printf("请输入职工性别(男/女):\n");
scanf("%s",&employee[i].sex);
printf("请输入职工成绩:\n");
scanf("%f",&employee[i].score);
}
printf("刚才所输入的职工信息是:\n");
printf("Num Name Sex Score\n");
for(i=0;i<N;i++)
scanf("%ld %s %s %f",&employee[i].num,&employee[i].name,&employee[i].sex,
&employee[i].score);
}