C语言课程设计报告—学籍信息管理系统剖析_第1页
C语言课程设计报告—学籍信息管理系统剖析_第2页
C语言课程设计报告—学籍信息管理系统剖析_第3页
C语言课程设计报告—学籍信息管理系统剖析_第4页
C语言课程设计报告—学籍信息管理系统剖析_第5页
已阅读5页,还剩16页未读 继续免费阅读

下载本文档

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

文档简介

1、 高级语言程序设计 说明书 设计题目:学籍信息管理系统 目录 题目要求 . 3 需求分析 . 3 总体设计 . 3 需求分析 . 3 解题的思路 . 3 定义结构 . 3 主程序的结构 . 3 功能菜单模块 . 6 输入模块 . 6 检查输入错误模块 . 6 7 . 输出模块 查询模块 . 7 排序模块 . 8 保存模块 . 9 读入模块 . 10 运行与测试报告 . 11 设计体会 . 13 附录 . 13 参考文献 . 20 学籍信息管理系统 一, 题目要求 1、需求分析:学生基本信息、学生成绩基本信息要存入文件当中,因而要提供文件的输入输出操作;查询功能要求提供查找和显示操作; 删除功能

2、要求实现删除操作; 排序功能要求实现排序操 作;另外还应该提供键盘式选择菜单以实现功能选择。 2、总体设计:整个系统可以设计为数据录入模块、数据查询模块、数据删除模块和数据排序模块。 二,需求分析 根据题目要求,学籍信息管理系统需要输入和输出等操作,在程序中,需要数据录入,查询,删除,删除和排序功能。 三,解题的思路 1.定义结构 2 typedef struct stud /学生信息结构 long num; char name20; float score; Stud; struct stud_type struct stud; char k3; int jilu; ; typedef st

3、ruct node Stud student; struct node *next; Node; 2.主程序的结构 void main() char choose; int flag=1; while (flag) duru(stu); /调用读入函数,读取文件信息; menu(); /调用功能菜单函数,显示菜单项。 printf( 请选择:); choose=getchar(); switch(choose) case 1: read(); /调用建立链表的函数;输出链表信息; print(); printf(Press any key Continue ); /getchar(); get

4、char(); break; case 2: /调用按学号查找学生信息的函数;并输出查找结果信息; long c; printf(input the number you want to find:); scanf(%ld,&c); find(c); printf(Press any key Continue.); 3 getchar(); break; case 3: /调用按姓名查找学生信息的函数;并输出查找结果信息; char s20; printf(input the name you want to find:); scanf(%s,s); searchname(s); printf

5、( Press any key Continue.); getchar(); getchar(); break; case 4: /调用根据学号删除某个学生信息的函数;并输出删除后的链表信息; Node *h; long n; printf(input the number you want to delete:); scanf(%ld,&n); h=del(n); if(h=NULL) printf(No find the student n); else print(); printf( Press any key Continue.); getchar(); getchar(); bre

6、ak; case 5: /调用插入新的学生信息的函数;并输出插入后的链表信息; long a; printf(input the number for the new:n); scanf(%ld,&a); inser(a); 2 ; print(); printf( Press any key Continue.); getchar(); getchar(); break; case 6: /调用按分数降序排序输出的函数;并输出排序后的链表信息; sort(1); print(); sort(0); printf(Press any key Continue.); getchar(); get

7、char(); 4 break; case 7: Save(stu); /调用保存函数,保存文件信息; print(); printf(Press any key Continue ); /getchar(); getchar(); break; case 0: /结束程序运行! flag=0; printf( * The End! *n); break; default: printf( Wrong Selection !(选择错误,重选)n); getchar(); 学籍管理系统数数数数数据据据据据储 录 查 排删 除 存序 询入 程序结束 3功能菜单模块 综合作业功能菜单 void me

8、nu() / 统n); 理系 printf( n 学 生信 息管 nn); printf( n 菜单 n); 数据录入 printf( n 1. 数据查询(学号)n); printf( n 2. n); printf( n 3. 数据查询(姓名) n); printf( n 4. 数据删除 5 printf( n 5. 数据插入n); printf( n 6. 数据排序n); printf( n 7. 保存文件信息 n); printf( n 0. 退 出nn); 4.输入模块 void read(void) long a; printf(input the number:); scanf(%

9、ld,&a); while(a0) 3 ; inser(a); printf(input the number:); scanf(%ld,&a); 5.检查输入错误模块 void inser(long b) Node *last,*current,*p; current=head; while(current!=NULL&bcurrent-student.num) last=current; current=current-next; if(current=NULL|bstudent.num) printf(input the name,score:); p=(Node *)malloc(si

10、zeof(Node); p-student.num=b; scanf(%s%f,,&p-student.score); p-next=NULL; if(current=head) p-next=head; head=p; Else p-next=current; last-next=p; 6 else if(b=current-student.num) printf(error input a different number:); 6.输出模块 void print() Node *p=head; 牰湩晴尨学号 姓名 成绩:n); while(p!=NULL) p

11、rintf(%ld %s %fn,p-student.num,,p-student.score); p=p-next; 4 ; printf(); 7查询模块 void find(long b) Node *p=head; while(p!=NULL&b!=p-student.num) p=p-next; if(!p) printf(No foundn); else 牰湩晴尨学号 姓名 成绩n); printf(%ld %s %fn,p-student.num,,p-student.score); void searchname(char

12、 *s) Node *p=head; int flag=0; 牰湩晴尨学号 姓名 成绩:n); while(p!=NULL) if(strcmp(,s)=0) printf(%ld %s %fn,p-student.num,,p-student.score); flag=1; p=p-next; continue; else p=p-next; 7 if(!flag) printf(No find); Node * del(long n) Node *p=head,*last; while(p-student.num!=n) last=p

13、; p=p-next; if(p=NULL) return p; else if(p=head) head=p-next; else last-next=p-next; 5 ; return head; 8.排序模块 void sort(int flag) /*flag=1 按分数排序 else 按学号排序*/ Node *p1,*p2,*k; float t1; long t2; char s20; for(p1=head;p1-next;p1=p1-next) k=p1; for(p2=p1-next;p2;p2=p2-next) if(flag=1&k-student.scorestud

14、ent.score|!flag&k-student.nump2-student.num) k=p2; if(k!=p1) t1=p1-student.score; p1-student.score=k-student.score; k-student.score=t1; t2=p1-student.num; p1-student.num=k-student.num; k-student.num=t2; strcpy(s,); strcpy(,); strcpy(,s); 8 9.

15、保存模块 void Save(struct stud_type stu) /*保存模块*/ int i; FILE *fp1; /*指向文件的指针*/ stu0.jilu=r; if(fp1=fopen(E:cj1.txt,wb)=NULL) /*打开文件,并判断打开是否正常,wb指只写打开或建立一个二进制文件,只允许写数据*/ printf(-打开文件失败!-nn); return; 牰湩晴尨开始存盘!n); for(i=0;ir;i+) if(fwrite(&stui,sizeof(struct stud_type),1,fp1)=0) printf(-数据存盘失败!-nn); fclos

16、e(fp1); printf(-存盘成功!-n); /*显示保存成功*/ 10.读入模块 void duru(struct stud_type stu) /*数据读入模块*/ int i; FILE *fp; /*指向文件的指针*/ if(fp=fopen(E:cj1.txt,b)=NULL) /*打开文件,并判断打开是否正常,rb指读写打开一个二进制文件,允许读和写*/ 牰湩晴尨打开文件失败!n); return; 牰湩晴尨文件开始读取!n); rewind(fp); for(i=0;i=r;i+) fread(&stui,sizeof(struct stud_type),1,fp); r=

17、stu0.jilu; printf(文件成功读取!n); fclose(fp); r=stu0.jilu; 9 四,运行与测试报告 10 11 五,设计体会 通过这次的程序设计实习,自己编写程序,从上百个错误慢慢的修改,经过自己的努力和老师的细心教导之下,错误逐渐的变少,最终可以运行了,这次的实习中,我磨练了自己的毅力和耐力,让我的信心倍增,在这短短的24的学时里,我体会到了苦与甜,更让我学到了很多的知识,在以后的工作中肯定会非常有用的,使对未来的生活充满了信心。 附录: #include #include #include #include #define N 100 typedef str

18、uct stud /学生信息结构 long num; char name20; float score; Stud; struct stud_type struct stud; char k3; int jilu; ; typedef struct node Stud student; struct node *next; Node; struct stud_type stuN; Node *head=NULL; void read(void); void inser(long b); void print(); void find(long b); void searchname(char

19、*s); Node * del(long n); void sort(int flag); void menu(); void Save(struct stud_type stu); void Print(struct stud_type stu); void duru(struct stud_type stu); 12 int r=0; void main() char choose; duru(stu); /调用读入函数,读取文件信息; int flag=1; while (flag) menu(); /调用功能菜单函数,显示菜单项。 printf( 请选择:); choose=getch

20、ar(); switch(choose) case 1: read(); /调用建立链表的函数;输出链表信息; print(); printf(Press any key Continue ); /getchar(); getchar(); break; case 2: /调用按学号查找学生信息的函数;并输出查找结果信息; long c; printf(input the number you want to find:); scanf(%ld,&c); find(c); printf(Press any key Continue.); getchar(); break; case 3: /调

21、用按姓名查找学生信息的函数;并输出查找结果信息; char s20; printf(input the name you want to find:); scanf(%s,s); searchname(s); printf( Press any key Continue.); /getchar(); getchar(); break; case 4: /调用根据学号删除某个学生信息的函数;并输出删除后的链表信息; Node *h; long n; printf(input the number you want to delete:); 13 scanf(%ld,&n); h=del(n);

22、if(h=NULL) printf(No find the student n); else print(); printf( Press any key Continue.); /getchar(); getchar(); break; case 5: /调用插入新的学生信息的函数;并输出插入后的链表信息; long a; printf(input the number for the new学号:n); scanf(%ld,&a); inser(a); print(); printf( Press any key Continue.); /getchar(); getchar(); bre

23、ak; case 6: /调用按分数降序排序输出的函数;并输出排序后的链表信息; sort(1); print(); sort(0); printf(Press any key Continue.); /getchar(); getchar(); break; case 7: Save(stu); /调用保存函数,保存文件信息; print(); printf(Press any key Continue ); /getchar(); getchar(); break; case 0: /结束程序运行! flag=0; printf( * The End! *n); break; defaul

24、t: printf( Wrong Selection !(选择错误,重选)n); getchar(); 14 void menu() /综合作业功能菜单 printf( n 学 生 信 息 管 理 系 统n); printf( n 菜 单nn); printf( n 1. 数据录入 n); printf( n 2. 数据查询(学号)n); printf( n 3. 数据查询(姓名) n); printf( n 4. 数据删除n); printf( n 5. 数据插入n); printf( n 6. 数据排序n); printf( n 7. 保存文件信息 n); printf( n 0. 退 出

25、nn); void read(void) long a; 牰湩晴尨学号:); scanf(%ld,&a); while(a0) inser(a); 牰湩晴尨学号:); scanf(%ld,&a); void inser(long b) Node *last,*current,*p; current=head; while(current!=NULL&bcurrent-student.num) last=current; current=current-next; if(current=NULL|bstudent.num) printf(input the 姓名,学分:); p=(Node *)

26、malloc(sizeof(Node); p-student.num=b; 15 scanf(%s%f,,&p-student.score); p-next=NULL; if(current=head) p-next=head; head=p; Else p-next=current; last-next=p; else if(b=current-student.num) printf(error input a different number:); void print() Node *p=head; 牰湩晴尨学号 姓名 成绩:n); while(p!=NULL

27、) printf(%ld %s %fn,p-student.num,,p-student.score); p=p-next; void find(long b) Node *p=head; while(p!=NULL&b!=p-student.num) p=p-next; if(!p) printf(No foundn); else 牰湩晴尨学号 姓名 成绩n); printf(%ld %s %fn,p-student.num,,p-student.score); void searchname(char *s) Node *p=head

28、; int flag=0; 牰湩晴尨学号 姓名 成绩:n); while(p!=NULL) if(strcmp(,s)=0) 16 printf(%ld %s %fn,p-student.num,,p-student.score); flag=1; p=p-next; continue; else p=p-next; if(!flag) printf(No find); Node * del(long n) Node *p=head,*last; while(p-student.num!=n) last=p; p=p-next; if(p

29、=NULL) return p; else if(p=head) head=p-next; else last-next=p-next; return head; void sort(int flag) /*flag=1 按分数排序 else 按学号排序*/ Node *p1,*p2,*k; float t1; long t2; char s20; for(p1=head;p1-next;p1=p1-next) k=p1; for(p2=p1-next;p2;p2=p2-next) if(flag=1&k-student.scorestudent.score|!flag&k-student.nump2-student.num) k=p2; if(k!=p1) t1=p1-student.score; p1-st

温馨提示

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

评论

0/150

提交评论