学生信息系统 链表 排序学生系统数据结构C程序Word下载.docx

上传人:b****6 文档编号:8450272 上传时间:2023-05-11 格式:DOCX 页数:20 大小:168.68KB
下载 相关 举报
学生信息系统 链表 排序学生系统数据结构C程序Word下载.docx_第1页
第1页 / 共20页
学生信息系统 链表 排序学生系统数据结构C程序Word下载.docx_第2页
第2页 / 共20页
学生信息系统 链表 排序学生系统数据结构C程序Word下载.docx_第3页
第3页 / 共20页
学生信息系统 链表 排序学生系统数据结构C程序Word下载.docx_第4页
第4页 / 共20页
学生信息系统 链表 排序学生系统数据结构C程序Word下载.docx_第5页
第5页 / 共20页
学生信息系统 链表 排序学生系统数据结构C程序Word下载.docx_第6页
第6页 / 共20页
学生信息系统 链表 排序学生系统数据结构C程序Word下载.docx_第7页
第7页 / 共20页
学生信息系统 链表 排序学生系统数据结构C程序Word下载.docx_第8页
第8页 / 共20页
学生信息系统 链表 排序学生系统数据结构C程序Word下载.docx_第9页
第9页 / 共20页
学生信息系统 链表 排序学生系统数据结构C程序Word下载.docx_第10页
第10页 / 共20页
学生信息系统 链表 排序学生系统数据结构C程序Word下载.docx_第11页
第11页 / 共20页
学生信息系统 链表 排序学生系统数据结构C程序Word下载.docx_第12页
第12页 / 共20页
学生信息系统 链表 排序学生系统数据结构C程序Word下载.docx_第13页
第13页 / 共20页
学生信息系统 链表 排序学生系统数据结构C程序Word下载.docx_第14页
第14页 / 共20页
学生信息系统 链表 排序学生系统数据结构C程序Word下载.docx_第15页
第15页 / 共20页
学生信息系统 链表 排序学生系统数据结构C程序Word下载.docx_第16页
第16页 / 共20页
学生信息系统 链表 排序学生系统数据结构C程序Word下载.docx_第17页
第17页 / 共20页
学生信息系统 链表 排序学生系统数据结构C程序Word下载.docx_第18页
第18页 / 共20页
学生信息系统 链表 排序学生系统数据结构C程序Word下载.docx_第19页
第19页 / 共20页
学生信息系统 链表 排序学生系统数据结构C程序Word下载.docx_第20页
第20页 / 共20页
亲,该文档总共20页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

学生信息系统 链表 排序学生系统数据结构C程序Word下载.docx

《学生信息系统 链表 排序学生系统数据结构C程序Word下载.docx》由会员分享,可在线阅读,更多相关《学生信息系统 链表 排序学生系统数据结构C程序Word下载.docx(20页珍藏版)》请在冰点文库上搜索。

学生信息系统 链表 排序学生系统数据结构C程序Word下载.docx

(三)实验要求

1、掌握线性结构的机器内表示;

2、掌握线性结构之上的算法设计与实现;

3、列表对比分析两种数据结构的相应操作的时间复杂度、空间复杂度,阐明产生差异的原因。

(四)问题描述

有一班学生上体育课排队,构成了一个单链表,链表的结点存储了学生的学号、姓名。

(五)基本要求

(1)从键盘输入学生的信息,建立学生链表。

(2)从键盘输入学生的信息,实现学生查询操作。

(3)从键盘输入学生的学号值,将学号为x的学生与其右边的学生进行交换。

(注:

不允许将链表中数据域的值进行交换)

(六)实验设计思路

实验实现9个功能,先在主函数main()设计声明每个函数,然后依次对每个函数细化,逐步调试,直到达到该函数的预期功能,即采用自顶向下,逐步细化的设计思路。

该实验全部采用单链表,设计一个学生信息系统,通过该系统一次可以完成:

1.创建学生系统2.学生系统排序3.删除学生信息4.增加学生信息5.查找学生信息6.清除学生信息7.修改学生信息8.模式查找信息9.退出学生系统等功能。

实验报告成绩:

(一)部分算法流程图

1删除学生信息

2学生信息模式查找

3选择排序

(二)函数算法

函数算法具体见程序代码。

(三)调试程序出现的问题及解决的方法

编程中出现很多的编译错误,我主要采用对每个函数调试,设断点,不会的问同学,链表的选择排序,在网上搜索,运用自己的程序中,让我更好的掌握了选择排序法。

(四)实验心得体会

通过这次试验,让我更好的掌握了链表的使用,用链表解决实际问题,用模块化程序设计思路,对每个函数细化,调试,使得整个程序正确运行,达到预期结果。

(五)程序清单

//学生系统.cpp:

定义控制台应用程序的入口点。

//

#include<

stdlib.h>

stdio.h>

string.h>

#definelen20

#defineNULL0

structstudent

{

charname[len];

charnumber[len];

};

structstdnode

studentdata;

stdnode*next;

voidcreatestd(stdnode*std)//创建学生系统

{

inti=0;

charch;

do{

std->

next=(stdnode*)malloc(sizeof(stdnode));

std=std->

next;

printf("

\t输入学生的学号和姓名:

\n\t"

);

scanf("

%s"

&

std->

data.number);

\t"

data.name);

getchar();

\t继续创建学生信息吗?

Y.继续N.退出\n\t"

%c"

ch);

}while(ch=='

Y'

std->

next=NULL;

}

voidinputstd(stdnode*std)

stdnode*p;

p=std->

if(p==NULL)printf("

\t没有学生信息!

\n"

printf("

\t现有学生信息如下表:

if(p!

=NULL)printf("

\t╔═════╤══════╗\n"

while(p!

=NULL)

{

\t║%10s│%11s║\n"

p->

data.number,p->

p=p->

\t╟─────┼──────╢\n"

}

if(std->

next!

\t╚═════╧══════╝\n"

voidsortstd(stdnode*std)//学生系统排序

charch;

stdnode*pi,*pj,*pipre,*pjpre,*ptem,*pmin,*pminpre;

\t选择排序方式:

A.姓名B.学号\n\t"

//按升序排列用选择排序法

getchar();

scanf("

next==NULL){printf("

exit(0);

if(ch=='

A'

{

pipre=std;

for(pi=std->

pi->

=NULL;

pi=pi->

next)

{

pmin=pi;

for(pj=pi->

next,pminpre=pi;

pj!

pminpre=pminpre->

next,pj=pj->

{

if(strcmp(pmin->

data.name,pj->

data.name)>

0)

{

pmin=pj;

pjpre=pminpre;

}

}

if(pmin->

next==NULL)

pipre->

next=pmin;

pmin->

next=pi->

pjpre->

next=pi;

pi->

else

if(pmin!

=pi)

pipre->

pjpre->

ptem=pmin->

pmin->

pi->

next=ptem;

pi=pipre->

pipre=pipre->

}

B'

data.number,pj->

data.number)>

pipre=pipre->

voiddeletestd(stdnode*std)//删除学生信息

stdnode*p,*pre=std;

intflag=1;

charch,choice[len];

\t选择删除方式:

A:

姓名B:

学号\n\t"

\t输入删除学生的姓名:

choice);

if(p==NULL)printf("

{

if(strcmp(p->

data.name,choice)==0)

{

pre->

next=p->

free(p);

flag=0;

printf("

\t删除成功!

break;

pre=p;

p=p->

if(flag)printf("

\t没有该学生!

elseif(ch=='

\t输入删除学生的学号:

data.number,choice)==0)

\t没有该学生,请重新输入!

voidincreasestd(stdnode*std)//增加学生信息

stdnode*p,*p1;

p1=(stdnode*)malloc(sizeof(stdnode));

\t输入增加学生的学号和姓名:

p1->

next=p1;

p1->

next=p;

\t信息添加成功!

voidseekstd(stdnode*std)//查找学生信息

charcho[len],ch;

\t选择查找方式:

A.名字B.学号\n\t"

\t请输入姓名:

cho);

if(strcmp(p->

data.name,cho)==0)

{

printf("

\t学生的信息如下:

\t姓名:

%s学号:

%s\n"

data.name,p->

flag=0;

\t没有该学生,请重新查找!

\t请输入学号:

if(strcmp(p->

data.number,cho)==0)

\t学号:

%s姓名:

data.number,p->

if(flag)printf("

voidclearstd(stdnode*std)//清空全部信息

p=p->

\t全部信息清空!

voidchangestd(stdnode*std)//修改学生信息

charch,seek[len];

\t选择修改方式:

\t输入要修改学生的姓名:

seek);

while(p!

if(strcmp(p->

data.name,seek)==0)

printf("

\t输入修改后学生的姓名:

scanf("

p->

flag=0;

break;

p=p->

if(flag==0)printf("

\t学生信息修改成功!

\t输入要修改学生的学号:

\t输入修改后学生的学号:

scanf("

break;

voidindex(stdnode*std)//模式查找信息

charseek[len],ch;

intnamelen,seeklen,i,j,flag=1;

\t选择匹配查找的方式:

\t输入姓名匹配字母:

seeklen=strlen(seek);

i=j=0;

namelen=strlen(p->

while(i<

namelen&

&

j<

seeklen)

if(p->

data.name[i]==seek[j]){i++;

j++;

else

i=i-j+1;

j=0;

if(j>

=seeklen)

flag=0;

\t输入学号匹配的数字:

if(p->

data.number[i]==seek[j]){i++;

intmain()

intch;

stdnodestd;

do

┌————————————————───——————————————————─┐\n"

│┈┈┈☆☆欢迎使用学生信息系统☆☆┈┈┈│\n"

│请选择下面操作│\n"

│1.创建学生系统2.学生系统排序3.删除学生信息│\n"

│4.增加学生信息5.查找学生信息6.清除学生信息│\n"

│7.修改学生信息8.模式查找信息9.退出学生系统│\n"

└—————————————————————————————————————─┘\n\t"

%d"

switch(ch)

case1:

createstd(&

std);

inputstd(&

break;

case2:

sortstd(&

case3:

deletestd(&

case4:

increasestd(&

case5:

seekstd(&

case6:

clearstd(&

case7:

changestd(&

case8:

index(&

case9:

┈┈┈┈┈┈┈┈┈☆☆欢迎下次使用学生信息系统☆☆┈┈┈┈┈┈┈┈┈┈┈┈┈\n"

}while(ch!

=9);

return0;

(六)测试结果

创建学生系统

学生系统排序

模式匹配查找

增加学生信息

实验结果与实验预期结果相符,符合实验要求。

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

当前位置:首页 > 求职职场 > 简历

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

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