这段代码的主要问题有6个.
语句后面没有分号';'。
访问结构体成员用'.'或'->',不能用','。
尽量不使用goto语句,并且你程序中写的"goto q;"是要去哪里?我已经帮你补上去了。
交换两个变量的值时,变量temp没有定义。
输出的时候文字排列不整齐,我帮你调整了一下。
没用引用命名空间。
下面是我修改后的代码。
#include
#include
#include
#include//最好不要重复引用头文件
using namespace std;//没用引用命名空间
struct student {
long num;
char name[10];
float achievement;
};//要有分号
student s[10];
int main()
#define M 10
#define N 20
#define P 35
#define Q 46
{
int i,a,b,c,d,e,f,g,h,k,m,n=0;
a=0;
b=0;
c=0;
d=0;
float max=0,min=0,sum=0;
char b1[10]="123456789";
char b2[10];
for(i=0; icout<
q:
cout<system("cls");//加一个清屏
for(i=0; icout<<'*';//改成字符
cout<cout<<'\n';
cout<cout<<'\n';
cout<for(i=0; i<30; i++)
cout<<' ';//改成字符
cout<cout< cout< cout< cout< cin>>c;
switch(c) {
case 1:
system("cls");
cout<cout<<"请依次输入10个学生的学号,姓名,成绩";
cout<for(d=0; d<10; d++)
cin>>s[d].num>>s[d].name>>s[d].achievement;//访问结构体成员用.或->,不能用,
cout<<"成绩输入成功";
cout<cin>>e;
if(e==0)
goto q;//尽量不使用goto语句
else
exit(0);
case 2:
system("cls");
cout<for(n=0; n<9; n++) {
c=n;
for(d=n+1; d<10; d++)
if(s[c].achievementif(c>n) {
student temp=s[c];
s[c]=s[n];
s[n]=temp;
}
}
for(n=0; n<10; n++) {
cout<}
cout<cin>>e;
if(e==0)
goto q;
else
exit(0);
case 3:
system("cls");
cout<<" 成绩分析系统"<f=g=h=k=0;//要初始化
for(n=0; n<10; n++) {
if(s[n].achievement>=90) f++;
else if(s[n].achievement >=80) g++;
else if(s[n].achievement>=60) h++;
else k++;
}
for(n=0; n<9; n++) {
c=n;
for(d=n+1; d<10; d++)
if(s[c].achievementif(c>n) {
student temp=s[c];//temp没有定义
s[c]=s[n];
s[n]=temp;
}
for(n=0; n<10; n++)
max=s[n].achievement;
}
cout<<'\t'<<'\t'<<'\t'<<"学号"<<'\t'<<'\t'<<"姓名"<<'\t'<<'\t'<<"成绩"<cout<<"最高分为:"<<'\t'<<'\t'< cout<<"最低分为:"<<'\t'<<'\t'<cout<<"平均分为:"<cout<<"90分以上的人数为:"< cout<<"80-90分的人数为:"< cout<<"60-80分的人数为:"< cout<<"60分以下的人数为:"< cout< cin>>e;
if(e==0)
goto q;
else
exit(0);
case 4:
system("cls");
cout<<"成绩分析系统"<cout<<"请输入你要查询学生的学号:"< {
cin>>m;
cout<<"学号\t姓名\t成绩"<for(n=0; n<10; n++)
if(m==s[n].num)
cout<}
cout<cin>>e;
if(e==0)
goto q;
else
exit(0);//没有分号
}
return 0;
}