#include "stdio.h"
typedef struct studentscore
{
char name[10];
char num[20];
struct subject
{char subname[20];
float score;
}sub[3];
//保存学生各科成绩
double total;
//总分
struct studentscore *next;
}STUCORE;
void insert()//插入学生成绩信息
{STUCORE *stu,*p;char k;p=head_2; int flag=0;
do
{stu=( STUCORE *) malloc(sizeof(STUCORE));
printf("输入学生的成绩信息:\n");
while(flag==0)
{
printf("请输入学生学号:");
scanf("%s",no);flag=Judge(no);
}
strcpy(stu->num,no);
printf("请输入学生姓名:");
scanf("%s",stu->name);
printf("请输入第一门课学科名:");
scanf("%s",stu->sub[0].subname);
printf("请输入该课成绩:");
scanf("%f",&stu->sub[0].score);
printf("请输入第二门课学科名:");
scanf("%s",stu->sub[1].subname);
printf("请输入该课成绩:");
scanf("%f",&stu->sub[1].score);
printf("请输入第三门课学科名:");
scanf("%s",stu->sub[2].subname);
printf("请输入该课成绩:");
scanf("%f",&stu->sub[2].score);
stu->sum=stu->sub[1].score+stu->sub[2].score+stu->sub[3].score;
stu->aver=sum/3.score;
getchar();printf("\t\t输入学生信息完成。\n");
while(p->next!=NULL)p=p->next;
p->next=stu;p=stu;p->next=NULL;
printf("\n添加完成后请去往文件管理保存!\n\n是否继续添加学生信息?(y/n):\n");
}
while((k=getchar())=='y');
getchar(); system("cls");
}
void delete_student()//删除学生成绩信息
{ STUCORE *p,*q;char no[10];char k,ch;
do
{
p=head_2;printf("\t\t删除学生的详细资料 \n\n\n");
printf("请输入要删除学生的学号:");scanf("%s",no);
while(strcmp(p->num,no)!=0&&p->next!=NULL) {q=p; p=p->next;}
if(strcmp((p->num),no)==0)
{
printf("要删除的学生成绩信息:");
printf("学号:%s\n",p->num);printf("姓名:%s\n",p->name);
printf("%s 成绩: %f\n",p->sub[0]subname,p->sub[0]score);
printf("%s 成绩: %f\n",p->sub[1]subname,p->sub[1]score);
printf("%s 成绩: %f\n",p->sub[2]subname,p->sub[2]score);
printf("平均分:%lf\n",p->aver);getchar();
printf("总分:%lf\n",p->total);getchar();
printf("\n确定删除吗?y/n?\n\n");ch=getchar();
if(ch=='y')
{q->next=p->next;printf("\n\t\t\t已删除该学生\n\n");}
}
else
printf("\n\t\t\t没有该学生\n\n");
getchar(); printf("\n删除完成后请去保存!\n\n是否继续删除其它学生信息?(y/n?):\n");k=getchar();
}
while(k=='y');
getchar();system("cls");
}
void correct()//修改学生成绩信息
{system("cls");STUCORE *p;char no[30];char k;
do
{p=head_2;printf("\t\t修改学生的详细资料\n");
printf("输入学生学号:");scanf("%s",no);
while(strcmp(p->num,no)!=0&&p->next!=NULL){ p=p->next;}
if(strcmp((p->num),no)==0)
{printf("要修改的学生的详细资料:\n");
printf("学号:%s\n",p->num);printf("姓名:%s\n",p->name);
printf("%s 成绩: %f\n",p->sub[0].subname,p->sub[0].score);
printf("%s 成绩: %f\n",p->sub[1].subname,p->sub[1].score);
printf("%s 成绩: %f\n",p->sub[2].subname,p->sub[2].score);
printf("平均分:%lf\n",p->aver);
printf("总分:%lf\n",p->total);
printf("\n\t\t********根据提示输入修改后的信息**********\n\n");
printf("输入新的学生的成绩信息:\n");
printf("请输入新的学生学号:");scanf("%s",p->num);
printf("请输入新的学生姓名:");scanf("%s",p->name);
printf("请输入第一门课学科名:");scanf("%s",stu->sub[0].subname);
printf("请输入该课成绩:");scanf("%f",&stu->sub[0].score);
printf("请输入第二门课学科名:");scanf("%s",stu->sub[1].subname);
printf("请输入该课成绩:");scanf("%f",&stu->sub[1].score);
printf("请输入第三门课学科名:");scanf("%s",stu->sub[2].subname);
printf("请输入该课成绩:");scanf("%f",&stu->sub[2].score);
stu->total=stu->sub[1].score+stu->sub[2].score+stu->sub[0].score;
stu->aver=total/3.score;
}
else
printf("\t\t没有此学生信息!\n\n");
getchar();
printf("\n修改完成后请保存!\n\n是否继修改学生信息?(y/n):\n");k=getchar();
}
while(k=='y');
getchar();
system("cls");
}
void preserve(void) //文件保存写入
{STUCORE *p;FILE *fp;
if((fp=fopen("file","wb+"))==NULL)
printf("\t\t\t文件无法正常打开!\n\n");
else
{p=head_2;
do
{fwrite(p,sizeof(STUCORE),1,fp);
p=p->next;}
while(p!=NULL);
}
fclose(fp);
}
void alter()//修改学生数据
{system("cls");int a;
printf("\t\t*************修改数据**************\n");
printf("\t\t**************************************\n");
printf("\t\t\t1:插入学生。\n");
printf("\t\t\t2:删除学生。\n");
printf("\t\t\t3:修改学生信息。\n");
printf("\t\t\t4:保存。\n");
printf("\t\t\t5:返回。\n");
printf("\t\t**************************************\n");
printf("\t\t**************************************\n");
printf("\n\t\t输入一个有效的数字,选择你要做的操作:\n");
scanf("%d",&a);
switch(a)
{
case 1:insert();break;
case 2:delete_student();break;
case 3:correct();break;
case 4:preserve();break;
case 5:menu_operation();break;
default:printf("\t\t\t错误的菜单选项\n\n");break;
}
}
void output_average(struct Student stu[N])
{
int A,B,C,D,E,i;
wenjian();/*****打开文件*****/
A=B=C=D=E=0;
for(i=0;i<N;i++)
{
if(stu[i].aver<60)/*****平均分低于60的人数******/
E++;
if(stu[i].aver>=60&&stu[i].aver<=69)/***平均分在60--69之间的人数***/
D++;
if(stu[i].aver>=70&&stu[i].aver<=79)/ ***平均分在70--79之间的人数***/
C++;
if(stu[i].aver>=80&&stu[i].aver<=89)/ ***平均分在80--89之间的人数***/
B++;
if(stu[i].aver>=90)
/****平均分大于89的人数***/
A++;
}
printf(">90\t80-89\t70-79\t60-69\t<60\n");
/****输出各分数段人数****/
printf("%d\t%d\t%d\t%d\t%d\n",E,D,C,B,A);
}
void output_computer(struct Student stu[N])
{
int A,B,C,D,E,i;
wenjian();/*****打开文件*****/
A=B=C=D=E=0;
for(i=0;i<N;i++)
{
if(stu[i].computer<60)/*****计算机分低于60的人数******/
E++;
if(stu[i].computer>=60&&stu[i].computer<=69)/***计算机分在60--69之间的人数***/
D++;
if(stu[i].computer>=70&&stu[i].computer<=79)/ ***计算机分在70--79之间的人数***/
C++;
if(stu[i].computer>=80&&stu[i].computer<=89)/ ***计算机分在80--89之间的人数***/
B++;
if(stu[i].computer>=90)
/****计算机分大于89的人数***/
A++;
}
printf(">90\t80-89\t70-79\t60-69\t<60\n");
/****输出各分数段人数****/
printf("%d\t%d\t%d\t%d\t%d\n",E,D,C,B,A);
}
void output_math(struct Student stu[N])
{
int A,B,C,D,E,i;
wenjian();/*****打开文件*****/
A=B=C=D=E=0;
for(i=0;i<N;i++)
{
if(stu[i].math<60)/*****数学分低于60的人数******/
E++;
if(stu[i].math>=60&&stu[i].math<=69)/***数学分在60--69之间的人数***/
D++;
if(stu[i].math>=70&&stu[i].math<=79)/ ***数学分在70--79之间的人数***/
C++;
if(stu[i].math>=80&&stu[i].math<=89)/ ***数学分在80--89之间的人数***/
B++;
if(stu[i].math>=90)
/****数学分大于89的人数***/
A++;
}
printf(">90\t80-89\t70-79\t60-69\t<60\n");
/****输出各分数段人数****/
printf("%d\t%d\t%d\t%d\t%d\n",E,D,C,B,A);
}
void output_english(struct Student stu[N])
{
int A,B,C,D,E,i;
wenjian();/*****打开文件*****/
A=B=C=D=E=0;
for(i=0;i<N;i++)
{
if(stu[i].english<60)/*****英语分低于60的人数******/
E++;
if(stu[i].english>=60&&stu[i].englishe<=69)/***英语分在60--69之间的人数***/
D++;
if(stu[i].english >=70&&stu[i].english<=79)/ ***英语分在70--79之间的人数***/
C++;
if(stu[i].english>=80&&stu[i].english<=89)/ ***英语分在80--89之间的人数***/
B++;
if(stu[i].english>=90)
/****英语分大于89的人数***/
A++;
}
printf(">90\t80-89\t70-79\t60-69\t<60\n");
/****输出各分数段人数****/
printf("%d\t%d\t%d\t%d\t%d\n",E,D,C,B,A);
}
void output_total(struct Student stu[N])
{
int A,B,C,D,E,i;
wenjian();/*****打开文件*****/
A=B=C=D=E=0;
for(i=0;i<N;i++)
{
if(stu[i].total<60)/*****英语分低于60的人数******/
E++;
if(stu[i].total>=60&&stu[i].total<=69)/***英语分在60--69之间的人数***/
D++;
if(stu[i].total>=70&&stu[i].total<=79)/ ***英语分在70--79之间的人数***/
C++;
if(stu[i].total>=80&&stu[i].total<=89)/ ***英语分在80--89之间的人数***/
B++;
if(stu[i].total>=90)
/****平均分大于89的人数***/
A++;
}
printf(">90\t80-89\t70-79\t60-69\t<60\n");
/****输出各分数段人数****/
printf("%d\t%d\t%d\t%d\t%d\n",E,D,C,B,A);
}
void output count(struct Student stu[N]
{system("cls");int a;
pri)ntf("\t\t**************************************\n");
printf("\t\t**************************************\n");
printf("\t\t\t1:计算机。\n");
printf("\t\t\t2:英语。\n");
printf("\t\t\t3:高数。\n");
printf("\t\t\t4:总分。\n");
printf("\t\t\t5:平均分。\n");
printf("\t\t\t6:退出。\n");
printf("\t\t**************************************\n");
printf("\t\t**************************************\n");
printf("\n\t\t输入一个有效的数字,选择你要做的操作:\n");scanf("%d",&a);
switch(a)
{case 1:computer();break;
case 2:math();break;
case 3:english();break;
case 4:total();break;
case 5:average();break;
case 6:menu_operation();break;
default:printf("\t\t\t错误的菜单选项\n\n");break;
}
}
C:\Windows\System32\002.cpp(16) : error C2065: 'head_2' : undeclared identifier
C:\Windows\System32\002.cpp(16) : error C2440: '=' : cannot convert from 'int' to 'struct studentscore *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
C:\Windows\System32\002.cpp(18) : error C2065: 'malloc' : undeclared identifier
C:\Windows\System32\002.cpp(23) : error C2065: 'no' : undeclared identifier
C:\Windows\System32\002.cpp(23) : error C2065: 'Judge' : undeclared identifier
C:\Windows\System32\002.cpp(25) : error C2065: 'strcpy' : undeclared identifier
C:\Windows\System32\002.cpp(40) : error C2039: 'sum' : is not a member of 'studentscore'
C:\Windows\System32\002.cpp(4) : see declaration of 'studentscore'
C:\Windows\System32\002.cpp(41) : error C2039: 'aver' : is not a member of 'studentscore'
C:\Windows\System32\002.cpp(4) : see declaration of 'studentscore'
C:\Windows\System32\002.cpp(41) : error C2059: syntax error : 'bad suffix on number'
C:\Windows\System32\002.cpp(41) : error C2146: syntax error : missing ';' before identifier 'score'
C:\Windows\System32\002.cpp(41) : error C2065: 'score' : undeclared identifier
C:\Windows\System32\002.cpp(48) : error C2065: 'system' : undeclared identifier
C:\Windows\System32\002.cpp(55) : error C2440: '=' : cannot convert from 'int' to 'struct studentscore *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
C:\Windows\System32\002.cpp(57) : error C2065: 'strcmp' : undeclared identifier
C:\Windows\System32\002.cpp(62) : error C2146: syntax error : missing ')' before identifier 'subname'
C:\Windows\System32\002.cpp(62) : error C2059: syntax error : ')'
C:\Windows\System32\002.cpp(63) : error C2146: syntax error : missing ')' before identifier 'subname'
C:\Windows\System32\002.cpp(63) : error C2059: syntax error : ')'
C:\Windows\System32\002.cpp(64) : error C2146: syntax error : missing ')' before identifier 'subname'
C:\Windows\System32\002.cpp(64) : error C2059: syntax error : ')'
C:\Windows\System32\002.cpp(65) : error C2039: 'aver' : is not a member of 'studentscore'
C:\Windows\System32\002.cpp(4) : see declaration of 'studentscore'
C:\Windows\System32\002.cpp(82) : error C2440: '=' : cannot convert from 'int' to 'struct studentscore *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
C:\Windows\System32\002.cpp(91) : error C2039: 'aver' : is not a member of 'studentscore'
C:\Windows\System32\002.cpp(4) : see declaration of 'studentscore'
C:\Windows\System32\002.cpp(97) : error C2065: 'stu' : undeclared identifier
C:\Windows\System32\002.cpp(97) : error C2227: left of '->sub' must point to class/struct/union
C:\Windows\System32\002.cpp(97) : error C2228: left of '.subname' must have class/struct/union type
C:\Windows\System32\002.cpp(98) : error C2227: left of '->sub' must point to class/struct/union
C:\Windows\System32\002.cpp(98) : error C2228: left of '.score' must have class/struct/union type
C:\Windows\System32\002.cpp(99) : error C2227: left of '->sub' must point to class/struct/union
C:\Windows\System32\002.cpp(99) : error C2228: left of '.subname' must have class/struct/union type
C:\Windows\System32\002.cpp(100) : error C2227: left of '->sub' must point to class/struct/union
C:\Windows\System32\002.cpp(100) : error C2228: left of '.score' must have class/struct/union type
C:\Windows\System32\002.cpp(101) : error C2227: left of '->sub' must point to class/struct/union
C:\Windows\System32\002.cpp(101) : error C2228: left of '.subname' must have class/struct/union type
C:\Windows\System32\002.cpp(102) : error C2227: left of '->sub' must point to class/struct/union
C:\Windows\System32\002.cpp(102) : error C2228: left of '.score' must have class/struct/union type
C:\Windows\System32\002.cpp(103) : error C2227: left of '->total' must point to class/struct/union
C:\Windows\System32\002.cpp(103) : error C2227: left of '->sub' must point to class/struct/union
C:\Windows\System32\002.cpp(103) : error C2228: left of '.score' must have class/struct/union type
C:\Windows\System32\002.cpp(103) : error C2227: left of '->sub' must point to class/struct/union
C:\Windows\System32\002.cpp(103) : error C2228: left of '.score' must have class/struct/union type
C:\Windows\System32\002.cpp(103) : error C2227: left of '->sub' must point to class/struct/union
C:\Windows\System32\002.cpp(103) : error C2228: left of '.score' must have class/struct/union type
C:\Windows\System32\002.cpp(104) : error C2227: left of '->aver' must point to class/struct/union
C:\Windows\System32\002.cpp(104) : error C2059: syntax error : 'bad suffix on number'
C:\Windows\System32\002.cpp(104) : error C2146: syntax error : missing ';' before identifier 'score'
C:\Windows\System32\002.cpp(121) : error C2440: '=' : cannot convert from 'int' to 'struct studentscore *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
C:\Windows\System32\002.cpp(148) : error C2065: 'menu_operation' : undeclared identifier
C:\Windows\System32\002.cpp(153) : error C2065: 'N' : undeclared identifier
C:\Windows\System32\002.cpp(153) : error C2057: expected constant expression
C:\Windows\System32\002.cpp(153) : error C2466: cannot allocate an array of constant size 0
C:\Windows\System32\002.cpp(156) : error C2065: 'wenjian' : undeclared identifier
C:\Windows\System32\002.cpp(160) : error C2036: 'struct Student []' : unknown size
C:\Windows\System32\002.cpp(160) : error C2027: use of undefined type 'Student'
C:\Windows\System32\002.cpp(153) : see declaration of 'Student'
C:\Windows\System32\002.cpp(160) : error C2228: left of '.aver' must have class/struct/union type
C:\Windows\System32\002.cpp(162) : error C2036: 'struct Student []' : unknown size
C:\Windows\System32\002.cpp(162) : error C2027: use of undefined type 'Student'
C:\Windows\System32\002.cpp(153) : see declaration of 'Student'
C:\Windows\System32\002.cpp(162) : error C2228: left of '.aver' must have class/struct/union type
C:\Windows\System32\002.cpp(162) : error C2036: 'struct Student []' : unknown size
C:\Windows\System32\002.cpp(162) : error C2027: use of undefined type 'Student'
C:\Windows\System32\002.cpp(153) : see declaration of 'Student'
C:\Windows\System32\002.cpp(162) : error C2228: left of '.aver' must have class/struct/union type
C:\Windows\System32\002.cpp(164) : error C2036: 'struct Student []' : unknown size
C:\Windows\System32\002.cpp(164) : error C2027: use of undefined type 'Student'
C:\Windows\System32\002.cpp(153) : see declaration of 'Student'
C:\Windows\System32\002.cpp(164) : error C2228: left of '.aver' must have class/struct/union type
C:\Windows\System32\002.cpp(164) : error C2036: 'struct Student []' : unknown size
C:\Windows\System32\002.cpp(164) : error C2027: use of undefined type 'Student'
C:\Windows\System32\002.cpp(153) : see declaration of 'Student'
C:\Windows\System32\002.cpp(164) : error C2228: left of '.aver' must have class/struct/union type
C:\Windows\System32\002.cpp(164) : error C2143: syntax error : missing ';' before '/'
C:\Windows\System32\002.cpp(164) : error C2018: unknown character '0xc6'
C:\Windows\System32\002.cpp(164) : error C2018: unknown character '0xbd'
C:\Windows\System32\002.cpp(164) : error C2018: unknown character '0xbe'
C:\Windows\System32\002.cpp(164) : error C2018: unknown character '0xf9'
C:\Windows\System32\002.cpp(164) : error C2018: unknown character '0xb7'
C:\Windows\System32\002.cpp(164) : error C2018: unknown character '0xd6'
C:\Windows\System32\002.cpp(164) : error C2018: unknown character '0xd4'
C:\Windows\System32\002.cpp(164) : error C2018: unknown character '0xda'
C:\Windows\System32\002.cpp(164) : error C2018: unknown character '0xd6'
C:\Windows\System32\002.cpp(164) : error C2018: unknown character '0xae'
C:\Windows\System32\002.cpp(164) : error C2018: unknown character '0xbc'
C:\Windows\System32\002.cpp(164) : error C2018: unknown character '0xe4'
C:\Windows\System32\002.cpp(164) : error C2018: unknown character '0xb5'
C:\Windows\System32\002.cpp(164) : error C2018: unknown character '0xc4'
C:\Windows\System32\002.cpp(164) : error C2018: unknown character '0xc8'
C:\Windows\System32\002.cpp(164) : error C2018: unknown character '0xcb'
C:\Windows\System32\002.cpp(164) : error C2018: unknown character '0xca'
C:\Windows\System32\002.cpp(164) : error C2018: unknown character '0xfd'
C:\Windows\System32\002.cpp(164) : warning C4138: '*/' found outside of comment
C:\Windows\System32\002.cpp(166) : error C2036: 'struct Student []' : unknown size
C:\Windows\System32\002.cpp(166) : error C2027: use of undefined type 'Student'
C:\Windows\System32\002.cpp(153) : see declaration of 'Student'
C:\Windows\System32\002.cpp(166) : error C2228: left of '.aver' must have class/struct/union type
C:\Windows\System32\002.cpp(166) : error C2036: 'struct Student []' : unknown size
C:\Windows\System32\002.cpp(166) : error C2027: use of undefined type 'Student'
C:\Windows\System32\002.cpp(153) : see declaration of 'Student'
C:\Windows\System32\002.cpp(166) : error C2228: left of '.aver' must have class/struct/union type
C:\Windows\System32\002.cpp(166) : error C2143: syntax error : missing ';' before '/'
C:\Windows\System32\002.cpp(166) : error C2018: unknown character '0xc6'
C:\Windows\System32\002.cpp(166) : error C2018: unknown character '0xbd'
C:\Windows\System32\002.cpp(166) : error C2018: unknown character '0xbe'
C:\Windows\System32\002.cpp(166) : error C2018: unknown character '0xf9'
C:\Windows\System32\002.cpp(166) : error C2018: unknown character '0xb7'
C:\Windows\System32\002.cpp(166) : error C2018: unknown character '0xd6'
C:\Windows\System32\002.cpp(166) : error C2018: unknown character '0xd4'
C:\Windows\System32\002.cpp(166) : error C2018: unknown character '0xda'
C:\Windows\System32\002.cpp(166) : fatal error C1003: error count exceeds 100; stopping compilation
执行 cl.exe 时出错.
怎么改啊?