📄 c语言の学生成绩管理系统.html
字号:
scanf("%s",findmess);<BR>
p=Locate(l,findmess,"name");<BR>
if(p)<BR>
{<BR>
r=l;<BR>
while(r->next!=p)<BR>
r=r->next;<BR>
r->next=p->next;<BR>
free(p);<BR>
printf("\n=====>提示:该学生已经成功删除!\n");<BR>
shoudsave=1;<BR>
}<BR>
else<BR>
Nofind();<BR>
}<BR>
else<BR>
Wrong();<BR>
}</FONT></P>
<P><FONT size=2>void Modify(Link l)<BR>
{<BR>
Node *p;<BR>
char findmess[20];<BR>
if(!l->next)<BR>
{<BR>
printf("\n=====>提示:没有资料可以修改!\n");<BR>
return;<BR>
}<BR>
printf("请你输入要修改的学生学号:");<BR>
scanf("%s",findmess);<BR>
p=Locate(l,findmess,"num");<BR>
if(p)<BR>
{<BR>
printf("请你输入新的c语言成绩(原来是%d分):",p->data.cgrade);<BR>
scanf("%d",&p->data.cgrade);<BR>
getchar();<BR>
printf("请你输入新的数学成绩(原来是%d分):",p->data.mgrade);<BR>
scanf("%d",&p->data.mgrade);<BR>
getchar();<BR>
printf("请你输入新的英语成绩(原来是%d分):",p->data.egrade);<BR>
scanf("%d",&p->data.egrade);<BR>
printf("\n=====>提示:资料修改成功!\n");<BR>
shoudsave=1;<BR>
}<BR>
else<BR>
Nofind();</FONT></P>
<P><FONT size=2>}</FONT></P>
<P><FONT size=2>void Disp(Link l)<BR>
{<BR>
int count=0;<BR>
Node *p;<BR>
p=l->next;<BR>
<BR>
if(!p)<BR>
{<BR>
printf("\n=====>提示:没有资料可以显示!\n");<BR>
return;<BR>
}<BR>
printf("\t\t\t\t显示结果\n");<BR>
printstart();<BR>
printc();<BR>
printf("\n");<BR>
while(p)<BR>
{<BR>
printe(p);<BR>
p=p->next;<BR>
}<BR>
printstart();<BR>
printf("\n");<BR>
}</FONT></P>
<P><FONT size=2>void Tongji(Link l)<BR>
{<BR>
Node *pm,*pe,*pc,*pt,*pa; //用于指向分数最高的接点<BR>
Node *r=l->next;<BR>
if(!r)<BR>
{<BR>
printf("\n=====>提示:没有资料可以统计!\n");<BR>
return ;<BR>
}<BR>
pm=pe=pc=pt=pa=r;<BR>
while(r)<BR>
{<BR>
if(r->data.cgrade>=pc->data.cgrade)<BR>
pc=r;<BR>
if(r->data.mgrade>=pm->data.mgrade)<BR>
pm=r;<BR>
if(r->data.egrade>=pe->data.egrade)<BR>
pe=r;<BR>
if(r->data.totle>=pt->data.totle)<BR>
pt=r;<BR>
if(r->data.ave>=pa->data.ave)<BR>
pa=r;</FONT></P>
<P><FONT size=2> r=r->next;<BR>
}<BR>
printf("------------------------------统计结果--------------------------------\n");<BR>
printf("总分最高者:\t%s %d分\n",pt->data.name,pt->data.totle);<BR>
printf("平均分最高者:\t%s %d分\n",pa->data.name,pa->data.ave);<BR>
printf("英语最高者:\t%s %d分\n",pe->data.name,pe->data.egrade);<BR>
printf("数学最高者:\t%s %d分\n",pm->data.name,pm->data.mgrade);<BR>
printf("c语言最高者:\t%s %d分\n",pc->data.name,pc->data.cgrade);<BR>
printstart();<BR>
}</FONT></P>
<P><FONT size=2>void Sort(Link l)<BR>
{<BR>
Link ll;<BR>
Node *p,*rr,*s;</FONT></P>
<P><FONT size=2>ll=(Link)malloc(sizeof(Node)); //用于做新的连表<BR>
ll->next=NULL;</FONT></P>
<P><FONT size=2>if(l->next==NULL)<BR>
{<BR>
printf("\n=====>提示:没有资料可以排序!\n");<BR>
return ;<BR>
}<BR>
p=l->next;<BR>
while(p)<BR>
{<BR>
s=(Node*)malloc(sizeof(Node)); //新建接点用于保存信息<BR>
s->data=p->data;<BR>
s->next=NULL;</FONT></P>
<P><FONT size=2> rr=ll;<BR>
while(rr->next!=NULL && rr->next->data.totle>=p->data.totle)<BR>
rr=rr->next;<BR>
if(rr->next==NULL)<BR>
rr->next=s;<BR>
else<BR>
{<BR>
s->next=rr->next;<BR>
rr->next=s;<BR>
}<BR>
p=p->next;<BR>
}<BR>
free(l);<BR>
l->next=ll->next;<BR>
printf("\n=====>提示:排序已经完成!\n");<BR>
}</FONT></P>
<P><FONT size=2>void Save(Link l)<BR>
{<BR>
FILE* fp;<BR>
Node *p;<BR>
int flag=1,count=0;<BR>
fp=fopen("g:\\student","wb");<BR>
if(fp==NULL)<BR>
{<BR>
printf("\n=====>提示:重新打开文件时发生错误!\n");<BR>
exit(1);<BR>
}<BR>
p=l->next;<BR>
<BR>
while(p)<BR>
{<BR>
if(fwrite(p,sizeof(Node),1,fp)==1)<BR>
{ <BR>
p=p->next;<BR>
count++;<BR>
}<BR>
else<BR>
{<BR>
flag=0;<BR>
break;<BR>
}<BR>
}<BR>
if(flag)<BR>
{<BR>
printf("\n=====>提示:文件保存成功.(有%d条记录已经保存.)\n",count);<BR>
shoudsave=0;<BR>
}<BR>
fclose(fp);<BR>
}</FONT></P>
<P><FONT size=2>void main()<BR>
{<BR>
Link l;//连表<BR>
FILE *fp; //文件指针<BR>
int sel;<BR>
char ch;<BR>
<BR>
int count=0;<BR>
Node *p,*r;<BR>
printf("\t\t\t\t学生成绩管理系统\n\t\t\t\t-------01软件院学 吴海松(200155304)\n");<BR>
l=(Node*)malloc(sizeof(Node));<BR>
l->next=NULL;<BR>
r=l;</FONT></P>
<P><FONT size=2>fp=fopen("C:\\student","ab+");<BR>
if(fp==NULL)<BR>
{<BR>
printf("\n=====>提示:文件不能打开!\n");<BR>
exit(0);<BR>
}<BR>
printf("\n=====>提示:文件已经打开,正在导入记录......\n");</FONT></P>
<P><FONT size=2>while(!feof(fp))<BR>
{<BR>
p=(Node*)malloc(sizeof(Node));<BR>
if(fread(p,sizeof(Node),1,fp)==1) //将文件的内容放入接点中<BR>
{<BR>
p->next=NULL;<BR>
r->next=p;<BR>
r=p; //将该接点挂入连中<BR>
count++;<BR>
}<BR>
}</FONT></P>
<P><FONT size=2>fclose(fp); //关闭文件<BR>
printf("\n=====>提示:记录导入完毕,共导入%d条记录.\n",count);<BR>
menu();<BR>
while(1)<BR>
{<BR>
printf("请你选择操作:");<BR>
scanf("%d",&sel);<BR>
<BR>
if(sel==0)<BR>
{<BR>
if(shoudsave==1)<BR>
{ getchar();<BR>
printf("\n=====>提示:资料已经改动,是否将改动保存到文件中(y/n)?\n");<BR>
scanf("%c",&ch);<BR>
if(ch=='y'||ch=='Y')<BR>
Save(l);<BR>
}<BR>
printf("\n=====>提示:你已经退出系统,再见!\n");<BR>
break;<BR>
}<BR>
switch(sel)<BR>
{<BR>
case 1:Add(l);break; //增加学生<BR>
case 2:Del(l);break;//删除学生<BR>
case 3:Qur(l);break;//查询学生<BR>
case 4:Modify(l);break;//修改学生<BR>
case 5:Disp(l);break;//显示学生<BR>
case 6:Tongji(l);break;//统计学生<BR>
case 7:Sort(l);break;//排序学生<BR>
case 8:Save(l);break;//保存学生<BR>
case 9:printf("\t\t\t==========帮助信息==========\n");menu();break;<BR>
default: Wrong();getchar();break;<BR>
}<BR>
}<BR>
}</FONT></P>
</FONT></STRONG>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -