c程序设计任务书Word文档下载推荐.docx

上传人:b****2 文档编号:1561055 上传时间:2023-04-30 格式:DOCX 页数:31 大小:392.55KB
下载 相关 举报
c程序设计任务书Word文档下载推荐.docx_第1页
第1页 / 共31页
c程序设计任务书Word文档下载推荐.docx_第2页
第2页 / 共31页
c程序设计任务书Word文档下载推荐.docx_第3页
第3页 / 共31页
c程序设计任务书Word文档下载推荐.docx_第4页
第4页 / 共31页
c程序设计任务书Word文档下载推荐.docx_第5页
第5页 / 共31页
c程序设计任务书Word文档下载推荐.docx_第6页
第6页 / 共31页
c程序设计任务书Word文档下载推荐.docx_第7页
第7页 / 共31页
c程序设计任务书Word文档下载推荐.docx_第8页
第8页 / 共31页
c程序设计任务书Word文档下载推荐.docx_第9页
第9页 / 共31页
c程序设计任务书Word文档下载推荐.docx_第10页
第10页 / 共31页
c程序设计任务书Word文档下载推荐.docx_第11页
第11页 / 共31页
c程序设计任务书Word文档下载推荐.docx_第12页
第12页 / 共31页
c程序设计任务书Word文档下载推荐.docx_第13页
第13页 / 共31页
c程序设计任务书Word文档下载推荐.docx_第14页
第14页 / 共31页
c程序设计任务书Word文档下载推荐.docx_第15页
第15页 / 共31页
c程序设计任务书Word文档下载推荐.docx_第16页
第16页 / 共31页
c程序设计任务书Word文档下载推荐.docx_第17页
第17页 / 共31页
c程序设计任务书Word文档下载推荐.docx_第18页
第18页 / 共31页
c程序设计任务书Word文档下载推荐.docx_第19页
第19页 / 共31页
c程序设计任务书Word文档下载推荐.docx_第20页
第20页 / 共31页
亲,该文档总共31页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

c程序设计任务书Word文档下载推荐.docx

《c程序设计任务书Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《c程序设计任务书Word文档下载推荐.docx(31页珍藏版)》请在冰点文库上搜索。

c程序设计任务书Word文档下载推荐.docx

b)可视化编程

c)源程序有足够的注释

d)上机调试通过

e)注重算法运用,优化存储效率与运算效率

二.系统设计

程序总体设计流程如图:

三.模块设计

1.模块划分:

a)主菜单b)输入模块

c)删除模块d)修改模块

e)查找模块f)统计模块

2.模块简介:

a)主菜单

start=fscanf();

//读入学生信息//

do

{printf("

\t\t欢迎进入学生信息管理系统\n"

);

printf("

1--添加学生信息\t\t2--修改学生信息\n3--删除学生信息\t\t4--按学号查找学生\n5--按姓名查找学生\t6--统计学生成绩\n7--学生成绩排序\t\t8--保存成文件\n9--输出信息\t\t10--退出\n"

scanf("

%d"

,&

choice);

switch(choice)

{

case1:

start=add(start);

break;

case2:

start=fix(start);

case3:

start=delet(start);

case4:

start=searchnum(start);

case5:

start=searchname(start);

case6:

start=tongji(start);

case7:

start=paixu(start);

print(start);

case8:

start=save(start);

case9:

case10:

default:

break;

}

}while(choice!

=10);

return0;

}

b)增加模块

structStudent*add(structStudent*head)//向已有链表添加新数据

{

if(head==NULL)

{

链表已为空\n4"

return(head);

}

structStudent*p1,*p2;

p2=head;

while(p2->

next!

=NULL)//找到表尾

p2=p2->

next;

p1=(structStudent*)malloc(LEN);

printf("

请输入姓名,学号,高数成绩,物理成绩,C语言成绩,英语成绩,并用空格分开\n"

scanf("

%s%d%d%d%d%d"

,p1->

name,&

p1->

num,&

score[0],&

score[1],&

score[2],&

score[3]);

p2->

next=p1;

p1->

next=NULL;

return(head);

c)删除模块

structStudent*delet(structStudent*head)//删除指定序号的节点

intnum;

链表为空\n"

请输入要删除学生的学号号:

\n"

num);

if(num<

=0){printf("

学号有误"

return(head);

p1=head;

while(num!

=p1->

num&

&

=NULL)//p1所指不是要找的节点数据且后面还有节点

p2=p1;

//指针后移

p1=p1->

if(num==p1->

num)//找到了指定序号

if(p1->

next==NULL&

p1==head)//只有一个节点

free(p1);

head=NULL;

else//有不止一个节点

if(p1==head)//所找数据在头节点

{

head=p1->

free(p1);

}

else//所找数据不在头节点

if(p1->

next==NULL)//所找数据在尾节点

{

p2->

next=p1->

free(p1);

}

else//所找数据在中间

else//找不到指定序号

没有该学号!

//返回删除完成后的链表头

d)修改模块

structStudent*fix(structStudent*head)//修改学生信息的函数//

structStudent*p1;

inti;

请输入需要需该学生信息的学号\n"

i);

if(i<

while(i!

=NULL)

p1=p1->

if(i==p1->

num)

{printf("

请输入修改后同学的信息:

"

else

学号不存在"

e)查找模块

structStudent*searchnum(structStudent*head)//按学号查询的函数//

{

姓名:

%s\n学号:

%d\n高数:

%d\n物理:

%d\nC语言:

%d\n英语:

%d\n"

name,p1->

num,p1->

score[0],p1->

score[1],p1->

score[2],p1->

structStudent*searchname(structStudent*head)//按姓名查找//

charname[6];

请输入需要需该学生信息的姓名\n"

%s"

,name);

while((strcmp(name,p1->

name))!

=0&

if((strcmp(name,p1->

name))==0)

姓名不存在"

f)统计模块

structStudent*tongji(structStudent*head)//统计学生成绩//

{intmin,max;

intj,n=0;

structStudent*p;

p=head;

请输入需要统计的课程(数字):

\n0、高数\t\t1、大物\t\t2、C语言\t\t3、英语\n"

j);

请输入所需分数段的下限和上限:

%d%d"

min,&

max);

while(p->

{if(p->

score[j]>

=min&

p->

score[j]<

=max)

n++;

p=p->

此分数段的学生数为:

%d\n\n"

,n);

g)排序模块

structStudent*paixu(structStudent*head)//冒泡法排序//

structStudent*i,*j,temp;

intx,z;

链表为空\n4"

请选择进行成绩排序的课程:

\n0。

高数\n1。

物理\n2。

C语言\n3。

英语\n"

x);

for(i=head;

i!

=NULL;

i=i->

next)//比较排序

for(j=i->

j!

j=j->

next)

if(j->

score[x]>

i->

score[x])

temp。

num=i->

num;

//利用temp结构体交换数据

i->

num=j->

j->

num=temp。

strcpy(temp。

name,i->

name);

strcpy(i->

name,j->

strcpy(j->

name,temp。

for(z=0;

z<

4;

z++)

{temp。

score[z]=i->

score[z];

score[z]=j->

j->

score[z]=temp。

//返回排序完成后的链表头

四.调试及测试

主菜单

1)增加信息

2)修改信息:

3)删除信息:

4)按学号查找

5)按姓名查找

6)统计学生成绩

输入任意的一个课程名(如C语言程序设计)和一个分数段(如70-80),统计出在此分数段的学生情况;

7)学生成绩排序

能对用户指定的任意课程名,按成绩升序或降序排列学生数据并显示排序结果

五.设计总结

以下是程序设计中遇到的一些问题,最终经过多次探索尝试都已解决,特把问题和解决方法总结与此:

1.无法将信息直接通过建立链表读出信息。

通过查资料以及和同学交流,我们选择利用fscanf函数从txt文档中直接读取。

然而,在进行这个操作的一开始,我们并不顺利,因为链表不能读取文档中存储的数据,最后通过排查,知道原因是因为字符串以空格为结束符,而我们规定以逗号为结束符,所以一开始不能读取数据。

对于文件储存,我们采用fprintf函数进行格式化读取,并且最后一000000为结束标志。

2.学生成绩在链表中的排序问题。

对于链表的排序,一开始我们觉得很迷茫。

经过一段时间的思考,我们最终选择了和数组排序一样的方法:

冒泡法。

这个我们主要通过比较两个节点中的学生成绩值,在满足条件的情况下将两个节点的值进行互换。

六.源代码

#include<

stdio。

h>

/*头文件*/

malloc。

stdlib。

string。

/*调用字符串函数的文件*/

#defineLENsizeof(structStudent)

structStudent//定义学生信息的结构体//

{charname[6];

intscore[4];

//由学生四门成绩组成的数组//

structStudent*next;

};

intn,choice;

intmain()

structStudent*fscanf();

//读入学生信息的函数//

voidprint(structStudent*head);

//输出学生信息的函数//

structStudent*add(structStudent*head);

//添加学生信息的函数//

structStudent*fix(structStudent*head);

//修改学生信息的函数//

structStudent*delet(structStudent*head);

//删除学生信息的函数//

structStudent*searchnum(structStudent*head);

//按学号查询学生信息的函数//

structStudent*searchname(structStudent*head);

//按姓名查询学生信息的函数//

structStudent*tongji(structStudent*head);

//统计学生成绩的函数//

structStudent*paixu(structStudent*head);

//排序函数//

structStudent*save(structStudent*head);

//保存信息的函数//

structStudent*start;

start=NULL;

printf("

已成功增添\n"

已成功修改\n"

structStudent*fscanf()//从文件读入

structStudent*head;

FILE*fp;

if((fp=fopen("

student。

txt"

,"

r"

))==NULL)

无链表文件\n"

exit(0);

n=0;

p1=p2=(structStudent*)malloc(LEN);

fscanf(fp,"

head=NULL;

while(p1->

num!

=0)//循环输入链表内容

n=n+1;

if(n==1)head=p1;

else

p2->

p1=(structStudent*)malloc(LEN);

fscanf(fp,"

请输入要删除学生的学号:

学号有误\n\n"

//指针后移

num)//找到了指定序号

p1==head)//只有一个节点

else//有不止一个节点

if(p1==head)//所找数据在头节点

else//所找数据不在头节点

已成功删除!

structStudent*paixu(s

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

当前位置:首页 > 经管营销 > 生产经营管理

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2