求解,帮忙看看这个代码怎么改啊?
#include <stdio.h>#include <string.h>
struct chengji
{
char name[20];
float math;
float chinese;
float english;
float chemistry;
float physics;
float sum;
int id;
};
int main()
{
struct chengji list[1000]={0};
int n,i;
printf("请输入学生总数:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
printf("\n请输入第%d个学生姓名及成绩:",i);
scanf("%s%d%f%f%f%f%f",list[i].name,&list[i].id,&list[i].math,&list[i].chinese,&list[i].english,&list[i].chemistry,&list[i].physi1cs);
list[i].sum=list[i].math+list[i].chinese+list[i].english+list[i].chemistry+list[i].physics;
list[0].math+=list[i].math;
list[0].chinese+=list[i].chinese;
list[0].english+=list[i].english;
list[0].chemistry+=list[i].chemistry;
list[0].physics+=list[i].physics;
}
printf("\t姓名\t学号\t数学\t语文\t英语\t化学\t物理\t总分\n");
for (i=1;i<=n;i++)
{
printf("\t%s\t%d\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f\n",list[i].name,list[i].id,list[i].math,list[i].chinese,list[i].english,list[i].chemistry,list[i].physics,list[i].sum);
}
printf("平均分:\t\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f\t\n",list[0].math,list[0].chinese,list[0].english,list[0].chemistry,list[0].physics);
return 0;
}
这是目前的代码
这是编译器说的错误:
52 27 E:\WORK\program\project.cpp [Error] expected unqualified-id before 'class'
54 42 E:\WORK\program\project.cpp [Error] expected primary-expression before 'class'
麻烦大家了!谢谢!