C语言课程设计报告学籍信息管理系统.docx

上传人:b****5 文档编号:7997231 上传时间:2023-01-27 格式:DOCX 页数:24 大小:148.22KB
下载 相关 举报
C语言课程设计报告学籍信息管理系统.docx_第1页
第1页 / 共24页
C语言课程设计报告学籍信息管理系统.docx_第2页
第2页 / 共24页
C语言课程设计报告学籍信息管理系统.docx_第3页
第3页 / 共24页
C语言课程设计报告学籍信息管理系统.docx_第4页
第4页 / 共24页
C语言课程设计报告学籍信息管理系统.docx_第5页
第5页 / 共24页
点击查看更多>>
下载资源
资源描述

C语言课程设计报告学籍信息管理系统.docx

《C语言课程设计报告学籍信息管理系统.docx》由会员分享,可在线阅读,更多相关《C语言课程设计报告学籍信息管理系统.docx(24页珍藏版)》请在冰豆网上搜索。

C语言课程设计报告学籍信息管理系统.docx

C语言课程设计报告学籍信息管理系统

 

《高级语言程序设计》

说明书

 

设计题目:

学籍信息管理系统

 

题目要求3

需求分析3

总体设计3

需求分析3

解题的思路3

定义结构3

主程序的结构3

功能菜单模块6

输入模块6

检查输入错误模块6

输出模块7

查询模块7

排序模块8

保存模块9

读入模块10

运行与测试报告11

设计体会13

附录13

参考文献20

 

学籍信息管理系统

一,题目要求

1、需求分析:

学生基本信息、学生成绩基本信息要存入文件当中,因而要提供文件的输入输出操作;查询功能要求提供查找和显示操作;删除功能要求实现删除操作;排序功能要求实现排序操作;另外还应该提供键盘式选择菜单以实现功能选择。

2、总体设计:

整个系统可以设计为数据录入模块、数据查询模块、数据删除模块和数据排序模块。

二,需求分析

根据题目要求,学籍信息管理系统需要输入和输出等操作,在程序中,需要数据录入,查询,删除,删除和排序功能。

三,解题的思路

1.定义结构

typedefstructstud//学生信息结构

{

longnum;

charname[20];

floatscore;

}Stud;

structstud_type

{

structstud;

chark[3];

intjilu;

};

typedefstructnode

{

Studstudent;

structnode*next;

}Node;

2.主程序的结构

voidmain()

{

charchoose;

intflag=1;

while(flag)

{

duru(stu);//调用读入函数,读取文件信息;

menu();//调用功能菜单函数,显示菜单项。

printf("请选择:

");

choose=getchar();

switch(choose)

{

case'1':

read();//调用建立链表的函数;输出链表信息;

print();

printf("\nPressanykeyContinue");

//getchar();

getchar();

break;

case'2':

//调用按学号查找学生信息的函数;并输出查找结果信息;

longc;

printf("inputthenumberyouwanttofind:

");

scanf("%ld",&c);

find(c);

printf("\nPressanykeyContinue.");

getchar();

break;

case'3':

//调用按姓名查找学生信息的函数;并输出查找结果信息;

chars[20];

printf("inputthenameyouwanttofind:

");

scanf("%s",s);

searchname(s);

printf("\nPressanykeyContinue.");

getchar();

getchar();

break;

case'4':

//调用根据学号删除某个学生信息的函数;并输出删除后的链表信息;

Node*h;

longn;

printf("inputthenumberyouwanttodelete:

");

scanf("%ld",&n);

h=del(n);

if(h==NULL)printf("Nofindthestudent\n");

elseprint();

printf("\nPressanykeyContinue.");

getchar();

getchar();

break;

case'5':

//调用插入新的学生信息的函数;并输出插入后的链表信息;

longa;

printf("inputthenumberforthenew:

\n");

scanf("%ld",&a);

inser(a);2;

print();

printf("\nPressanykeyContinue.");

getchar();

getchar();

break;

case'6':

//调用按分数降序排序输出的函数;并输出排序后的链表信息;

sort

(1);

print();

sort(0);

printf("\nPressanykeyContinue.");

getchar();

getchar();

break;

case'7':

Save(stu);//调用保存函数,保存文件信息;

print();

printf("\nPressanykeyContinue");

//getchar();

getchar();

break;

case'0':

//结束程序运行!

flag=0;

printf("\n***TheEnd!

***\n");

break;

default:

printf("\nWrongSelection!

(选择错误,重选)\n");

getchar();

}

}

}

3.功能菜单模块

voidmenu()//综合作业功能菜单

{

printf("\n学生信息管理系统\n");

printf("\n菜单\n\n");

printf("\n1.数据录入\n");

printf("\n2.数据查询(学号)\n");

printf("\n3.数据查询(姓名)\n");

printf("\n4.数据删除\n");

printf("\n5.数据插入\n");

printf("\n6.数据排序\n");

printf("\n7.保存文件信息\n");

printf("\n0.退出\n\n");}

4.输入模块

voidread(void)

{

longa;

printf("inputthenumber:

");

scanf("%ld",&a);

while(a>0){3;

inser(a);

printf("inputthenumber:

");

scanf("%ld",&a);

}

5.检查输入错误模块

voidinser(longb)

{

Node*last,*current,*p;

current=head;

while(current!

=NULL&&b>current->student.num)

{

last=current;

current=current->next;

}

if(current==NULL||bstudent.num)

{

printf("inputthename,score:

");

p=(Node*)malloc(sizeof(Node));

p->student.num=b;

scanf("%s%f",p->student.name,&p->student.score);

p->next=NULL;

if(current==head)

{

p->next=head;

head=p;

}

Else

{

p->next=current;

last->next=p;

}

}

elseif(b==current->student.num)

printf("errorinputadifferentnumber:

");

}

6.输出模块

voidprint()

{

Node*p=head;

printf("学号姓名成绩:

\n");

while(p!

=NULL)

{

printf("%ld%s%f\n",p->student.num,p->student.name,p->student.score);

p=p->next;

}4;

printf("\n");

}

7.查询模块

voidfind(longb)

{

Node*p=head;

while(p!

=NULL&&b!

=p->student.num)

p=p->next;

if(!

p)printf("Nofound\n");

else

{

printf("学号姓名成绩\n");

printf("%ld%s%f\n",p->student.num,p->student.name,p->student.score);

}

}

voidsearchname(char*s)

{

Node*p=head;

intflag=0;

printf("学号姓名成绩:

\n");

while(p!

=NULL)

{

if(strcmp(p->student.name,s)==0)

{

printf("%ld%s%f\n",p->student.num,p->student.name,p->student.score);

flag=1;

p=p->next;

continue;

}

elsep=p->next;

}

if(!

flag)printf("Nofind");

}

Node*del(longn)

{

Node*p=head,*last;

while(p->student.num!

=n){

last=p;

p=p->next;

}

if(p==NULL)returnp;

elseif(p==head)head=p->next;

elselast->next=p->next;5;

returnhead;

}

8.排序模块

voidsort(intflag)

{

/*flag==1按分数排序else按学号排序*/

Node*p1,*p2,*k;

floatt1;

longt2;

chars[20];

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.num>p2->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,p1->student.name);

strcpy(p1->student.name,k->student.name);

strcpy(k->student.name,s);

}

}

}

9.保存模块

voidSave(structstud_typestu[])/*保存模块*/

{

inti;

FILE*fp1;/*指向文件的指针*/

stu[0].jilu=r;

if((fp1=fopen("E:

\\cj1.txt","wb"))==NULL)/*打开文件,并判断打开是否正常,wb指只写打开或建立一个二进制文件,只允许写数据*/

{

printf("----------打开文件失败!

----------\n\n");

return;

}

printf("开始存盘!

\n");

for(i=0;i

if(fwrite(&stu[i],sizeof(structstud_type),1,fp1)==0)

printf("----------数据存盘失败!

----------\n\n");

fclose(fp1);

printf("----------存盘成功!

----------\n");/*显示保存成功*/

}

10.读入模块

voidduru(structstud_typestu[])/*数据读入模块*/

{

inti;

FILE*fp;/*指向文件的指针*/

if((fp=fopen("E:

\\cj1.txt","rb"))==NULL)/*打开文件,并判断打开是否正常,rb指读写打开一个二进制文件,允许读和写*/

{

printf("打开文件失败!

\n");

return;

}

printf("文件开始读取!

\n");

rewind(fp);

for(i=0;i<=r;i++)

{

fread(&stu[i],sizeof(structstud_type),1,fp);

r=stu[0].jilu;

}

printf("\n文件成功读取!

\n");

fclose(fp);

r=stu[0].jilu;

}

}

 

四,运行与测试报告

五,设计体会

通过这次的程序设计实习,自己编写程序,从上百个错误慢慢的修改,经过自己的努力和老师的细心教导之下,错误逐渐的变少,最终可以运行了,这次的实习中,我磨练了自己的毅力和耐力,让我的信心倍增,在这短短的24的学时里,我体会到了苦与甜,更让我学到了很多的知识,在以后的工作中肯定会非常有用的,使对未来的生活充满了信心。

附录:

#include

#include

#include

#include

#defineN100

typedefstructstud//学生信息结构

{

longnum;

charname[20];

floatscore;

}Stud;

structstud_type

{

structstud;

chark[3];

intjilu;

};

typedefstructnode

{

Studstudent;

structnode*next;

}Node;

structstud_typestu[N];

Node*head=NULL;

voidread(void);

voidinser(longb);

voidprint();

voidfind(longb);

voidsearchname(char*s);

Node*del(longn);

voidsort(intflag);

voidmenu();

voidSave(structstud_typestu[]);

voidPrint(structstud_typestu[]);

voidduru(structstud_typestu[]);

intr=0;

voidmain()

{

charchoose;

duru(stu);//调用读入函数,读取文件信息;

intflag=1;

while(flag)

{

menu();//调用功能菜单函数,显示菜单项。

printf("请选择:

");

choose=getchar();

switch(choose)

{

case'1':

read();//调用建立链表的函数;输出链表信息;

print();

printf("\nPressanykeyContinue");

//getchar();

getchar();

break;

case'2':

//调用按学号查找学生信息的函数;并输出查找结果信息;

longc;

printf("inputthenumberyouwanttofind:

");

scanf("%ld",&c);

find(c);

printf("\nPressanykeyContinue.");

getchar();

break;

case'3':

//调用按姓名查找学生信息的函数;并输出查找结果信息;

chars[20];

printf("inputthenameyouwanttofind:

");

scanf("%s",s);

searchname(s);

printf("\nPressanykeyContinue.");

//getchar();

getchar();

break;

case'4':

//调用根据学号删除某个学生信息的函数;并输出删除后的链表信息;

Node*h;

longn;

printf("inputthenumberyouwanttodelete:

");

scanf("%ld",&n);

h=del(n);

if(h==NULL)printf("Nofindthestudent\n");

elseprint();

printf("\nPressanykeyContinue.");

//getchar();

getchar();

break;

case'5':

//调用插入新的学生信息的函数;并输出插入后的链表信息;

longa;

printf("inputthenumberforthenew学号:

\n");

scanf("%ld",&a);

inser(a);

print();

printf("\nPressanykeyContinue.");

//getchar();

getchar();

break;

case'6':

//调用按分数降序排序输出的函数;并输出排序后的链表信息;

sort

(1);

print();

sort(0);

printf("\nPressanykeyContinue.");

//getchar();

getchar();

break;

case'7':

Save(stu);//调用保存函数,保存文件信息;

print();

printf("\nPressanykeyContinue");

//getchar();

getchar();

break;

case'0':

//结束程序运行!

flag=0;

printf("\n***TheEnd!

***\n");

break;

default:

printf("\nWrongSelection!

(选择错误,重选)\n");

getchar();

}

}

}

voidmenu()//综合作业功能菜单

{

printf("\n学生信息管理系统\n");

printf("\n菜单\n\n");

printf("\n1.数据录入\n");

printf("\n2.数据查询(学号)\n");

printf("\n3.数据查询(姓名)\n");

printf("\n4.数据删除\n");

printf("\n5.数据插入\n");

printf("\n6.数据排序\n");

printf("\n7.保存文件信息\n");

printf("\n0.退出\n\n");

}

voidread(void)

{

longa;

printf("学号:

");

scanf("%ld",&a);

while(a>0)

{

inser(a);

printf("学号:

");

scanf("%ld",&a);

}

}

voidinser(longb)

{

Node*last,*current,*p;

current=head;

while(current!

=NULL&&b>current->student.num)

{

last=current;

current=current->next;

}

if(current==NULL||bstudent.num)

{

printf("inputthe姓名,学分:

");

p=(Node*)malloc(sizeof(Node));

p->student.num=b;

scanf("%s%f",p->student.name,&p->student.score);

p->next=NULL;

if(current==head)

{

p->next=head;

head=p;

}

Else

{

p->next=current;

last->next=p;

}

}

elseif(b==current->student.num)

printf("errorinputadifferentnumber:

");

}

voidprint()

{

Node*p=head;

printf("学号姓名成绩:

\n");

while(p!

=NULL){

printf("%ld%s%f\n",p->student.num,p->student.name,p->student.score);

p=p->next;

}

voidfind(longb)

{

Node*p=head;

while(p!

=NULL&&b!

=p->student.num)

p=p->next;

if(!

p)printf("Nofound\n");

else{

printf("学号姓名成绩\n");

printf("%ld%s%f\n",p->student.num,p->student.name,p->student.score);

}

voidsearchname(char*s)

{

Node*p=head;

intflag=0;

printf("学号姓名成绩:

\n");

while(p!

=NULL)

{

if(strcmp(p->student.name,s)==0)

{

printf("%ld%s%f\n",p->student.num,p->student.name,p->s

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 农林牧渔 > 林学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1