C语言课设学生信息管理系统_第1页
C语言课设学生信息管理系统_第2页
C语言课设学生信息管理系统_第3页
C语言课设学生信息管理系统_第4页
C语言课设学生信息管理系统_第5页
已阅读5页,还剩10页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、开始流程图:非法选项9.调用ha函数馆&调用Sa函数rt7.调用SOW&调用5.调用hrc§)i数yImo函数4.调用ad函数e3.调用de心1.调用PI引函数同ere函数结束全局变量structstudcharname20;longnum;intage;charsex;intscore3;chartele12;structstud*next;子程序1 .creat()函数y 继续,输入 n 停功能:创建链表,提示输入学生信息,储存到链表中,录入完成后输入止,返回主菜单2 .display()函数功能:显示当前已经存入链表的信息3 .dele()函数功能:删除链表中学

2、生信息,可按姓名或学号删除4 .add()函数功能:按学号插入学生信息5 .modify()函数功能:修改链表中学生信息6 .search()函数功能:查找学生信息,可按学号或姓名查找7.sort()函数功能:对信息进行排序,可实现分别对三门成绩排序8.save()函数功能:将链表中的数据保存到指定文件9.load()函数功能:将指定文件中已有的数据读入链表源程序#include<stdio.h>#include<string.h>#include<stdlib.h>#include<conio.h>structstudcharname20;lo

3、ngnum;intage;charsex;intscore3;chartele12;structstud*next;main()structstud*head;structstud*creat(void);voiddisplay(structstud*head);structstud*dele(structstud*head);structstud*add(structstud*head);structstud*modify(structstud*head);voidsearch(structstud*head);voidsave(structstud*head);structstud*sor

4、t(structstud*head);voidsave(structstud*head);structstud*load();charch;head=NULL;for(;)clrscr();/*清屏函数*/printf( printf(nnttWelcometostudentinformationmanagementnnt*printf(nttt1:Enter the information ”);printf(nttt2:List the information ”);printf(nttt3:Delete the information ”);printf(nttt4:Add the in

5、formation ”);printf(nttt5:Modify the information ”);printf(nttt6:Search the information ”);printf(nttt7:Sort the information ”);printf(nttt8:Save the information ”);printf(nttt9:Load the information ”);printf(nttt0:Exit “);printf(ntttEnter your choice: ”);system” );”);fflush(stdin);ch=getchar();getc

6、har();switch(ch)case1:head=creat();break;case2:display(head);system(“pause”);break;case3:head=dele(head);system(“pause”);break;case4:head=add(head);system(“pause”);break;case5:head=modify(head);system(“pause”);break;case6:search(head);system(“pause”);break;case7:head=sort(head);system(“pause”);break

7、;case8:save(head);system(“pause”);break;case9:head=load();break;case0:return;break;default:clrscr();printf(“ntError!Pleasecheckyourinputnn”);system(“pause”);structstud*creat(void)/*链表的创建*/structstud*head,*p1;charch;clrscr();head=NULL;p1=(structstud*)malloc(sizeof(structstud);printf(“tentername:”);ge

8、ts(p1->name);printf(“tenternumber:”);scanf(“%ld”,&p1->num);printf(“tenterage:”);scanf(“%d”,&p1->age);printf(“tentersex:”);fflush(stdin);scanf(“%c”,&p1->sex);printf(“tenterMathscore:”);scanf(“%d”,&p1->score0);printf(“tenterEnglishscore:”);scanf(“%d”,&p1->score1);

9、printf(“tenterCscore:”);scanf(“%d”,&p1->score2);printf(“tentertelephonenumber:”);fflush(stdin);gets(p1->tele);head=p1;p1->next=NULL;doprintf(“ntDOYOUWANTTOCONTINUE?YorN?”);printf(“ntEnteryourchoise:”);fflush(stdin);ch=getchar();clrscr();if(ch=y|ch=Y)head=add(head);elseif(ch!=N&&

10、ch!=n)printf(“ntError!Pleasecheckyourinput”);ch=y;链表的删除*/while(ch=y|ch=Y);return(head);structstud*dele(structstud*head)/*structstud*p1,*p2;intchoose;longdelnum;charname20;clrscr();printf(“nttChoosethewayyouwantprintf(“nt1:Accordingtonamenprintf(“nt2:Accordingtonumnprintf(“ntEnteryourchoice:scanf(“%d

11、”,&choose);fflush(stdin);if(choose=1)printf(“ntEnterthename:”);gets(name);if(head=NULL)printf(););););tnNoinformation!n”);return(head);p1=head;while(strcmp(name,p1->name)!=0&&p1->next!=NULL)p2=p1;p1=p1->next;if(strcmp(name,p1->name)=0)if(p1=head)head=p1->next;elsep2->ne

12、xt=p1->next;printf(“tDeleteSuccessed!nn”);elseprintf(“tNotbeenfind!nn”);return(head);elseif(choose=2)printf(“ntEnterthenumber:”);scanf(“%ld”,&delnum);if(head=NULL)printf(“nNoinformation!n”);return(head);p1=head;while(delnum!=p1->num&&p1->next!=NULL)p2=p1;p1=p1->next;if(delnum

13、=p1->num)if(p1=head)head=p1->next;elsep2->next=p1->next;printf(“tDeleteSuccessed!nn”);elseprintf(“tNotbeenfind!n”);return(head);elseprintf(“ntError!Pleasecheckyourinputnn”);return(head);voiddisplay(structstud*head)structstud*p;p=head;clrscr();if(head=NULL)printf(“ntNoinformationnn”);else

14、printf(“nametnumbertagetsextMathtEnglishtCttelephonenumbern”);doprintf(“%st%ldt%dt%ct%dt%dt%dt%sn”,p->name,p->num,p->age,p->sex,p->score0,p->score1,p->score2,p->tele);p=p->next;while(p!=NULL);structstud*add(structstud*head)/*链表的插入*/structstud*p1,*p2,*p0;p0=(structstud*)mal

15、loc(sizeof(structstud);clrscr();printf(“nttInputtheinformation:”);printf(“nttname:”);fflush(stdin);gets(p0->name);printf(“ttnumber:”);scanf(“%ld”,&p0->num);printf(“tt”age:”);scanf(“%d”,&p0->age);printf(“ttsex:”);fflush(stdin);scanf(“%c”,&p0->sex);printf(“ttMathscore:”);scanf(

16、“%d”,&p0->score0);printf(“ttEnglishscore:”);scanf(“%d”,&p0->score1);printf(“ttCscore:”);scanf(“%d”,&p0->score2);printf(“tttelephonenumber:”fflush(stdin);gets(p0->tele);p1=head;if(head=NULL)head=p0;p0->next=NULL;elsewhile(p0->num>p1->num)p2=p1,p1=p1->next;if(p0-

17、>num<=p1->num)if(head=p1)head=p0;elsep2->next=p0;p0->next=p1;elsep1->next=p0;p0->next=NULL;return(head);structstud*modify(structstud*head)/*链表的修改*/structstud*p1,*p2,*p0;clrscr();printf(“ntInputthestudentsname:”);p0=(structstud*)malloc(sizeof(structstud);fflush(stdin);gets(p0->

18、;name);if(head=NULL)printf(“nNoinformation!nn”);return(head);p1=head;while(strcmp(p0->name,p1->name)!=0&&p1->next!=NULL)p2=p1;p1=p1->next;if(strcmp(p0->name,p1->name)=0);printf(“nametnumbertagetsextMathtEnglishtCttelephonenumbernprintf( “%st%ldt%dt%ct%dt%dt%dt%sn,p1->nam

19、e,p1->num,p1->age,p1->sex,p1->score0,p1->score1,p1->score2,p1->tele);if(p1=head)head=p1->next;elsep2->next=p1->next;printf(“tNewinformation:number:”);scanf(“%ld”,&p0->num);printf(“tttage:”);scanf(“%d”,&p0->age);printf(“tttsex:”);fflush(stdin);scanf(“%c”,&a

20、mp;p0->sex);printf(“tttMathscore:”);scanf(“%d”,&p1->score0);printf(“tttEnglishscore:”);scanf(“%d”,&p1->score1);printf(“tttCscore:”);scanf(“%d”,&p1->score2);printf(“ttttelephonenumber:”);fflush(stdin);gets(p0->tele);p1=head;if(head=NULL)head=p0;p0->next=NULL;elsewhile(p0

21、->num>p1->num)p2=p1;p1=p1->next;if(p0->num<=p1->num)if(head=p1)head=p0;elsep2->next=p0;p0->next=p1;elsep1->next=p0;p0->next=NULL;printf(“ModifySuccessed!nn”);elseprintf(“Notbeenfind!nn”);return(head);voidsearch(structstud*head)/*查询链表*/structstud*p;intchoose;longnum;c

22、harname20;clrscr();printf(“nttChoosethewayyouwant”);printf(“nt1:Accordingtonamen“);printf(“nt2:Accordingtonumn”);printf(“ntEnteryourchoice:”);scanf(“%d”,&choose);fflush(stdin);if(choose=1)printf(“ntenterthename:”);gets(name);if(head=NULL)printf(“tnNoinformation!nn”);elsep=head;while(strcmp(name,

23、p->name)!=0&&p->next!=NULL)p=p->next;if(strcmp(name,p->name)=0)printf(“nametnumbertagetsextMathtEnglishtCttelephonenumbern”);printf(“%st%ldt%dt%ct%dt%dt%dt%sn”,p->name,p->num,p->age,p->sex,p->score0,p->score1,p->score2,p->tele);elseprintf(“Notbeenfind!nn”)

24、;elseif(choose=2)printf(“ntEnterthenumber:”);scanf(“%ld”,&num);if(head=NULL)printf(“nNoinformation!n”);elsep=head;while(num!=p->num&&p->next!=NULL)p=p->next;if(num=p->num)printf(“nametnumbertagetsextMathtEnglishtCttelephonenumbern”);printf(“%st%ldt%dt%ct%dt%dt%dt%sn”,p->na

25、me,p->num,p->age,p->sex,p->score0,p->score1,p->score2,p->tele);elseprintf(“tNotbeenfind!n”);elseprintf(“ntError!Pleasecheckyourinputnn”);structstud*sort(structstud*head)structstud*first;structstud*t;structstud*p;structstud*q;int ch; clrscr(); printf( printf( printf( printf( prin

26、tf( scanf(nttChoose the way you wantntntntnt1: According to Math:n2: According to Englishn3: According to Cn Enter your choice:%d” ,&ch);););” ););” );first = head->next;head->next = NULL;while (first != NULL)for (t=first, q=head; (q!=NULL) && q=q->next);(q->scorech-1>t-&g

27、t;scorech-1);p=q,first = first->next;if (q = head)head=t;elsep->next=t;t->next=q;printf(“nttSuccess!n”);returnhead;voidsave(structstud*head)/*保存链表*/FILE*fp;structstud*p;charfilename20;printf(“nninputthefilename:“);fflush(stdin);gets(filename);if(fp=fopen(filename,”w”)=NULL)printf(“Savefile%

28、serror!Typeitagain.nn”,filename);exit(0);p=head;while(p!=NULL)fprintf(fp,”%st”,p->name);fprintf(fp,”%ldt”,p->num);fprintf(fp,”%dt”,p->age);fprintf(fp,”%ct”,p->sex);fprintf(fp,”%dt”,p->score0)fprintf(fp,”%dt”,p->score1)fprintf(fp,”%dt”,p->score2)fprintf(fp,”%stn”,p->tele);p=p-

29、>next;printf(“nttSuccess!n”);fclose(fp);structstud*load()/*链表的导入*/FILE*fp;charfilename20;structstud*head,*p1,*p2;printf(“nninputthefilename:“);fflush(stdin);gets(filename);if(fp=fopen(filename,”r”)=NULL)printf(“Loadfile%serror!Typeitagain.nn”,filename);exit(0);if(!feof(fp)head=(strfscanf(fp,fscanf(fp,fscanf(fp,fscanf(fp,fscanf(fp,fscanf(fp,fscanf(fp,fsc

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论