求解error: syntax error before "int"
这个代码总是在红色行出现error: syntax error before "int",是怎么回事?
#include <stdio.h>
struct stu
{
char name[100];
int n;
int physics;
int math;
};
int main()
{
int i,t,sum,ave,max,total;//i循环变量,t代换求分段人数 sum分数求和 ave分数平均 max 最大值 total选课人数,temp四舍五入用
float temp;
int a[5]={0},b[5]={0};
struct stu student[10];
for(i=0;i<10;i++){
scanf("%s %d %d %d",student[i].name,&student[i].n,&student[i].physics,&student[i].math);
}
sum=0;
max=0;
total=0;
for(i=0;i<10;i++){
t=student[i].physics/10;
if(t>0){
sum += student[i].physics;
switch(t){
case 10:a[0]+=1;break;
case 9:a[0]+=1;break;
case 8:a[1]+=1;break;
case 7:a[2]+=1;break;
case 6:a[3]+=1;break;
default :a[4]+=1;break;
}
}
if(max<student[i].physics){
max=student[i].physics;
}
}
total=a[0]+a[1]+a[2]+a[3]+a[4];
temp=(float)sum/total;
ave=((int)(temp+0.5)==(int)temp) ? (int)temp:int(temp+0.5);
printf("physics:%d(%.2f);%d(%.2f);%d(%.2f);%d(%.2f);%d(%.2f);%d;\n",a[0],(float)a[0]/total,a[1],(float)a[1]/total,a[2],(float)a[2]/total,a[3],(float)a[3]/total,a[4],(float)a[4]/total,ave);
for(i=0;i<10;i++){
if(student[i].physics==max)
printf("physics:%s;%d;%d;\n",student[i].name,student[i].n,student[i].physics);
}
sum=0;
max=0;
total=0;
for(i=0;i<10;i++){
t=student[i].math/10;
if(t>0){
sum+=student[i].math;
switch(t){
case 10:b[0]+=1;break;
case 9:b[0]+=1;break;
case 8:b[1]+=1;break;
case 7:b[2]+=1;break;
case 6:b[3]+=1;break;
default :b[4]+=1;break;
}
}
if(max<student[i].math){
max=student[i].math;
}
}
total=b[0]+b[1]+b[2]+b[3]+b[4];
temp=(float)sum/total;
ave=((int)(temp+0.5)==(int)temp) ? (int)temp:int(temp+0.5);
printf("math:%d(%.2lf);%d(%.2lf);%d(%.2lf);%d(%.2lf);%d(%.2lf);%d;\n",b[0],(float)b[0]/total,b[1],(float)b[1]/total,b[2],(float)b[2]/total,b[3],(float)b[3]/total,b[4],(float)b[4]/total,ave);
for(i=0;i<10;i++){
if(student[i].math==max)
printf("math:%s;%d;%d;\n",student[i].name,student[i].n,student[i].math);
}
return 0;
}