数据结构课程设计报告Word文件下载.docx

上传人:b****1 文档编号:13283596 上传时间:2022-10-09 格式:DOCX 页数:48 大小:121.94KB
下载 相关 举报
数据结构课程设计报告Word文件下载.docx_第1页
第1页 / 共48页
数据结构课程设计报告Word文件下载.docx_第2页
第2页 / 共48页
数据结构课程设计报告Word文件下载.docx_第3页
第3页 / 共48页
数据结构课程设计报告Word文件下载.docx_第4页
第4页 / 共48页
数据结构课程设计报告Word文件下载.docx_第5页
第5页 / 共48页
点击查看更多>>
下载资源
资源描述

数据结构课程设计报告Word文件下载.docx

《数据结构课程设计报告Word文件下载.docx》由会员分享,可在线阅读,更多相关《数据结构课程设计报告Word文件下载.docx(48页珍藏版)》请在冰豆网上搜索。

数据结构课程设计报告Word文件下载.docx

4④删除学生成绩;

5按总成绩降序排序。

2.基本要求:

该题目涉及到单链表的各种操作,包括单链表的建立、结点的查找、插入、删除等基本运算。

首先建立学生成绩单链表,链表中每个结点由4个域组成,分别为:

学号、姓名、成绩、存放下一个结点地址的next域。

然后将要求完成的四项功能写成四个函数,登记学生成绩对应建立学生单链表的功能,后三个功能分别对应单链表的查询、插入与删除三大基本操作。

3.算法思想:

Creat()函数算法思想:

从0至n循环输入n个同学的三科成绩,并且计算总成绩。

Inquiry()函数算法思想:

将学号与已输入的所有学号做比较,一旦相同则输出该学号信息,否则显示没有该学生信息。

Insert()函数算法思想:

生成一个新节点,然后将其接到原有链表尾部。

Delete()函数算法思想:

通过ID找到该节点,并删去该节点。

Sort(函数算法思想:

利用排序算法对每一个节点作比较并更换其在链表中的位置顺序。

4.模块划分

(1)LinkListCreat(LinkListT,intn)其功能是创造节点,录入成绩。

(2)voidInquiry(LinkListT)其功能是查询与已知ID一致的学生信息并展示出来。

(3)voidInsert(LinkListT,intn)其功能是添加若干个学生的成绩信息。

(4)voidDelete(LinkListT)其功能是删除若干个学生的成绩信息。

(5)voidSort(LNode*p)其功能是排序并展示若干个学生的成绩信息。

5.数据结构:

数据类型LNode定义如下:

typedefstructLNode

{

intID;

charname[20];

intscore1;

intscore2;

intscore3;

inttotal;

structLNode*next;

}LNode,*LinkList;

6.源程序:

源代码

//main.c

#include<

stdio.h>

stdlib.h>

typedefstructLNode

LinkListCreat(LinkListT,intn);

voidDelete(LinkListT);

voidInquiry(LinkListT);

voidInsert(LinkListT,intn);

voidSort(LNode*p);

voidInsert(LinkListT,intn)

inti;

LNode*r=T,*p;

while((r->

next)!

=NULL)

{

r=r->

next;

}

for(i=0;

i<

n;

i++)

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

printf("

Pleaseenterthestudent'

sstudentID:

"

);

scanf("

%d"

&

p->

ID);

sname:

"

%s"

p->

name);

sscore1:

score1);

sscore2:

score2);

sscore3:

score3);

p->

total=p->

score1+p->

score2+p->

score3;

Thetotalscoreis%d\n"

total);

next=NULL;

r->

next=p;

r=p;

\nInsertiscomplete!

}

voidInquiry(LinkListT)

intid;

PleaseenterthestudentIDyouwanttoinquireabout:

id);

LNode*p=T;

p=p->

while(p!

if(p->

ID==id)

\nThestudentscoresinformationhasbeensuccessfullyinquired!

\n"

ID:

%d\nName:

%s\nScore1:

%d\nScore2:

%d\nScore3:

%d\n"

ID,p->

name,p->

score1,p->

score2,p->

break;

else

if(!

p)

Sorry!

Didnotinquirythestudentscoresinformation!

voidDelete(LinkListT)

intid,flag=1;

PleaseenterthestudentIDyouwanttodeleteabout:

//LNode*q;

while((p->

next->

//q=p->

next=p->

//deleteq;

\nThestudentscoresinformationhasbeensuccessfullydeleted!

flag=0;

break;

if(flag)

Didnotdeletethestudentscoresinformationyouwanttodelete!

voidSort(LNode*p)

LNode*r,*qian,*hou;

qian=p->

hou=qian->

while(hou)

if(qian->

total>

=hou->

total)

qian=hou;

hou=hou->

}//if

while(r->

hou->

qian->

next=hou->

hou->

next=r->

next=hou;

hou=qian->

}//else

inti=1;

while(p)

Num:

%d\nID:

%d\ntotal:

%d\n\n"

i,p->

score3,p->

i++;

LinkListCreat(LinkListT,intn)

LNode*p,*r;

T=(LNode*)malloc(sizeof(LNode));

T->

r=T;

returnT;

intmain()

LNode*p;

intn;

while

(1)

system("

cls"

StudentScoresManagement\n\n"

1-Enterthestudent'

sscore\n"

2-Querythestudent'

3-Insertthestudent'

4-Deletethestudent'

5-Sortthestudent'

0-Exitsystem\n\n"

Pleaseenteranumberselection(0-5):

intchoice;

choice);

if(choice==0)

exit(0);

switch(ch

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

当前位置:首页 > 成人教育 > 自考

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

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