📄 学生成绩管理系统_数据结构与算法_数据结构算法_c语言_c 语言之家.htm
字号:
修改'!\n",num);<BR> printstart();<BR> printc();<BR> printe(s);<BR> printstart();<BR> printf("\n");<BR> return;<BR> }<BR> s=s->next;<BR> }<BR> <BR> p=(Node
*)malloc(sizeof(Node));<BR> <BR> strcpy(p->data.num,num);<BR> printf("请你输入姓名:");<BR> scanf("%s",p->data.name);<BR> getchar();<BR> printf("请你输入性别:");<BR> scanf("%s",p->data.sex);<BR> getchar();<BR> printf("请你输入c语言成绩:");<BR> scanf("%d",&p->data.cgrade);<BR> getchar();<BR> printf("请你输入数学成绩:");<BR> scanf("%d",&p->data.mgrade);<BR> getchar();<BR> printf("请你输入英语成绩:");<BR> scanf("%d",&p->data.egrade);<BR> getchar();<BR> p->data.totle=p->data.egrade+p->data.cgrade+p->data.mgrade;<BR> p->data.ave=p->data.totle
/
3;<BR> //信息输入已经完成<BR> p->next=NULL;<BR> r->next=p;<BR> r=p;<BR> shoudsave=1;<BR> <BR> }<BR>}</FONT></P>
<P><FONT size=2>void Qur(Link l)
//查询学生<BR>{<BR> int sel;<BR> char
findmess[20];<BR> Node
*p;<BR> if(!l->next)<BR> {<BR> printf("\n=====>提示:没有资料可以查询!\n");<BR> return;</FONT></P>
<P><FONT
size=2> }<BR> printf("\n=====>1按学号查找\n=====>2按姓名查找\n");<BR> scanf("%d",&sel);<BR> if(sel==1)//学号<BR> {<BR> printf("请你输入要查找的学号:");<BR> scanf("%s",findmess);<BR> p=Locate(l,findmess,"num");<BR> if(p)<BR> {<BR> printf("\t\t\t\t查找结果\n");<BR> printstart();<BR> printc();<BR> printe(p);<BR> printstart();<BR> }<BR> else<BR> Nofind();<BR> }<BR> else
if(sel==2)
//姓名<BR> {<BR> printf("请你输入要查找的姓名:");<BR> scanf("%s",findmess);<BR> p=Locate(l,findmess,"name");<BR> if(p)<BR> {<BR> printf("\t\t\t\t查找结果\n");<BR> printstart();<BR> printc();<BR> printe(p);<BR> printstart();<BR> }<BR> else<BR> Nofind();<BR> }<BR> else<BR> Wrong();<BR> <BR>}</FONT></P>
<P><FONT size=2>void Del(Link l)
//删除<BR>{<BR> int sel;<BR> Node
*p,*r;<BR> char
findmess[20];<BR> if(!l->next)<BR> {<BR> printf("\n=====>提示:没有资料可以删除!\n");<BR> return;<BR> }<BR> printf("\n=====>1按学号删除\n=====>2按姓名删除\n");<BR> scanf("%d",&sel);<BR> if(sel==1)<BR> {<BR> printf("请你输入要删除的学号:");<BR> scanf("%s",findmess);<BR> p=Locate(l,findmess,"num");<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
if(sel==2)<BR> {<BR> printf("请你输入要删除的姓名:");<BR> 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>}<BR></FONT></P><BR></FONT></TD></TR></TBODY></TABLE></TD></TR>
<TR>
<TD height=25 width="100%">
<DIV align=center></DIV></TD></TR>
<TR>
<TD height=20 width=255><A class=bottom
href="http://www.cstudyhome.com/wenzhang06/review.asp?NewsID=4401"
target=_blank> <IMG
border=0 height=18
src="学生成绩管理系统_数据结构与算法_数据结构算法_C语言_C 语言之家.files/icon1.gif"
width=18> <FONT color=blue>发表评论</FONT></A> </TD></TR>
<TR>
<TD width="100%">
<HR SIZE=1>
</TD></TR>
<TR>
<TD height=8></TD></TR>
<TR>
<TD height=18 width="100%"><B>相关专题:</B>
<TR>
<TD width="100%">
<HR SIZE=1>
</TD></TR>
<TR>
<TD height=8></TD></TR>
<TR>
<TD height=18 width="100%"><B>相关信息:</B></TD></TR>
<TR>
<TD height=8></TD></TR>
<TR>
<TD width="100%"> 没有相关信息</TD></TR>
<TR>
<TD width="100%">
<HR SIZE=1>
</TD></TR>
<TR>
<TD height=8></TD></TR>
<TR>
<TD width="100%"><B>相关评论:</B></TD></TR>
<TR>
<TD height=8></TD></TR>
<TR>
<TD width="100%"></TD></TR>
<TR>
<TD>
<TABLE border=0 cellPadding=5 cellSpacing=0
width="100%">
<TBODY>
<TR bgColor=#d1e4fc>
<TD width="100%">发表人:寒冰 发表人邮件:<A
href="mailto:zhanghui21@avl.com.cn">zhanghui21@avl.com.cn</A> 发表时间:2004-9-29
0:04:49</TD>
<TD width=270>
<P align=right></P></TD></TR>
<TR>
<TD bgColor=#ffffff
colSpan=2>你在vc上面运通了吗?<BR>我调了很久都没有调通哦
</TD></TR></TD></TR></TBODY></TABLE>
<HR noShade SIZE=1>
</TD></TR>
<TR>
<TD>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -